84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
为什么有的代码<script></script>插在<head></head>标签中,有的插在<body></body>标签中?这两种有什么区别?
越努力越幸运!!!
<script></script>Where is the tag? -PHP Chinese website Q&A-Where is the <script></script> tag? -PHP Chinese website Q&A
Please watch and learn.
可以放在HTML页面中的任意位置
放在<head>部分
最常用的方式是在页面中head部分放置<script>元素,浏览器解析head部分就会执行这个代码,然后才解析页面的其余部分。进行页面初始化的js必须放在head里面。
放在<body>部分JavaScript代码在网页读取到该语句的时候就会执行
<script></script>Where is the tag? -PHP Chinese website Q&A-Where is the <script></script> tag? -PHP Chinese website Q&A
Please watch and learn.
可以放在HTML页面中的任意位置
放在<head>部分
最常用的方式是在页面中head部分放置<script>元素,浏览器解析head部分就会执行这个代码,然后才解析页面的其余部分。进行页面初始化的js必须放在head里面。
放在<body>部分
JavaScript代码在网页读取到该语句的时候就会执行