1.js在html中的位置有哪些
head、body、body并列、html并列、外部都可以
2.示例js脚本
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta charset="UTF-8">
<title>js内部定义、外部引用</title>
<script>
alert("hello 4")
</script>
</head>
<body>
<script>
alert("hello js!")
</script>
</body>
<script>
alert("hello 2")
</script>
<!-- 引用外部js脚本 -->
<script src="../demo.js"></script>
</html>
<!-- 脚本可以放在任意位置,一般与body标签并列 -->
<script>
alert("hello 3")
</script>
3.外部脚本
放置在html文件同级目录
alert("外部js脚本")