首页 > 编程语言 > 详细

JavaScript——引入JavaScript

时间:2021-04-23 00:16:31      阅读:16      评论:0      收藏:0      [点我收藏+]

 

1.内部标签

1 <script>
2       alert(‘hello world!‘)
3       ....
4 </script>

 

2.外部引入

      xxx.js

alert(‘hello world!‘)

     xxx.html

 <script src="js/xxx.js"></script>

 

测试代码

    

html代码

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Title</title>
 6 
 7 <!--内部标签-->
 8      <!--script标签内写Javascript代码   -->
 9      <!--    <script>-->
10      <!--        alert(‘hello world!‘)-->
11      <!--    </script>-->
12 
13 
14 <!--外部引入-->
15      <!--注意:script标签必须成对出现-->
16     <script src="js/qj.js"></script>
17 
18      <!--不要显示定义type,也默认就是javascript-->
19     <script type="text/javascript">
20 
21     </script>
22 
23 </head>
24 <body>
25 
26 
27 <!--这里也可以存放-->
28 </body>
29 </html>

 

js代码

1 alert(‘嘿嘿,你好啊!‘)

 

JavaScript——引入JavaScript

原文:https://www.cnblogs.com/clblogs/p/14691070.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!