1 <!-- 1、行间事件(主要用于事件) 2 <input type="button" name="" onclick="alert('ok! ');""> 3 4 2、页面script标签嵌入 5 <script type="text/javascript">alret('ok!');</script> 6 7 3、外部引入 8 <script type="text/javascript" src="js/index.js"></script> --> 9 10 <!DOCTYPE html> 11 <html lang="en"> 12 <head> 13 <meta charset="UTF-8"> 14 <title>Document</title> 15 <!-- 第三种:外部引用 --> 16 <script type="text/javascript"> 17 alert('hello world too'); 18 </script> 19 <!-- 第二种:嵌入式 --> 20 <script type="text/javascript" src="hello.js"></script> 21 </head> 22 <body> 23 <!-- 第一种:行间事件 --> 24 <input type="button" name="" value="点击" onclick="alert('hello world')"> 25 </body> 26 </html>