html怎么和js连接
时间:2021-07-01 15:03
方法:1、直接将js代码嵌入script标签对中,语法“<script>js代码</script>”;2、将js代码写入一个“.js”文件中,使用“<script src="js文件路径"></script>”语句引入该js文件即可。 本教程操作环境:windows7系统、javascript1.8.5版、Dell G3电脑。 js和HTML结合(连接)有两种方式 第一种:直接将js代码嵌入script标签对中 语法 第二种:使用script标签,引入一个外部js文件 *** 创建一个js文件,写js代码 ***然后使用以下语句引入 使用第二种方式的时候,就不要在script标签里面写js代码了,不会执行。 示例: 【相关推荐:javascript学习教程】 以上就是html怎么和js连接的详细内容,更多请关注www.gxlsystem.com其它相关文章!<script type="text/javascript"> js代码; </script>
<script type="text/javascript" src="js文件路径"></script>
<html>
<head>
<title>World</title>
<style type="text/css">
</style>
</head>
<body>
<script type="text/javascript">
alert("aaaaaa");
</script>
</body>
</html>
<html>
<head>
<title>World</title>
<style type="text/css">
</style>
</head>
<body>
<script type="text/javascript" src="1.js">
//alert("bbbbb"); 没有效果
</script>
</body>
</html>