码迷,mamicode.com
首页 > 编程语言 > 详细

[Js高手之路第一部]JavaScript上百例实战【新版】_1 js代码三种书写方式

时间:2018-05-06 13:37:17      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:class   书写方式   div   val   页面   javascrip   oct   input   doctype   

 

小结:

javascript使用的3种方式:

1,页面script方式

2,行间事件触发

3,外部引入方式

 

1,页面script方式

 

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6     <script>
 7         alert(1);
 8     </script>
 9 </head>
10 <body>
11 
12 </body>
13 </html>

 

2,行间事件触发

 

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6 </head>
 7 <body>
 8     <input type="button" value="点击以后弹出1" onclick="alert(1);">
 9 </body>
10 </html>

 

3,外部引入方式

 

.html

 

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6     <script src="./js/main.js"></script>
 7 </head>
 8 <body>
 9     
10 </body>
11 </html>

 

.js

 

alert(1);

 

[Js高手之路第一部]JavaScript上百例实战【新版】_1 js代码三种书写方式

标签:class   书写方式   div   val   页面   javascrip   oct   input   doctype   

原文地址:https://www.cnblogs.com/denggelin/p/8997797.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!