<script></script>的三种用法:
- 放在<body>中
- 放在<head>中
- 放在外部JS文件中
在body中:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script> document.write("段落一") function date () { window.alert(Date()) } </script> </body> </html>
在head中:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script> function btu(){ document.getElementById("d2").innerHTML="金拱门"; } </script> </head> <body> <script> document.write("段落一") function date () { window.alert(Date()) } </script> <p id="d2">麦当劳</p> <button type="button"
转载于:https://www.cnblogs.com/Naiky/p/7742657.html




