一、初识JavaScript
JavaScript是脚本语言,插入html中使用
二、使用JavaScript
1、必须位于script标签之间
2、可被放置在 HTML 页面的 body 和 head 部分
-
必须位于script标签之间
<script> <p>第一个JavaScript</p> </script>
-
可被放置在 HTML 页面的 body 和 head 部分
例:放置body中
<!DOCTYPE html> <html> <body> <script> document.write("<h1>第一个JavaScript</h1>"); document.write("<p>第一个JavaScript</p>"); </script> </body> </html>
例:放置head中
<!DOCTYPE html> <html> <head> <script> document.write("<h1>第一个JavaScript</h1>"); document.write("<p>第一个JavaScript</p>"); </script> </head> <body> </body> </html>