2、编写javascript的方式
2.1、行内js
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>第一个js程序</title>
</head>
<body>
<input type="button" onclick="javascript:alert('这是行内js')" value="测试">
</body>
</html>
html关注的页面的骨架
css关注的页面的美观
js关注的是页面的行为、动作
2.2、内部js
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>第一个js程序</title>
    <script type="text/javascript">
        alert("helloworld");
        alert("挂机");
    </script>
</head>
<body>
<input type="button"   value="测试">
</body>
</html>
2.3、外部js
首先定义个js文件(index.js)
alert("helloworld");
alert("挂机");
然后在html页面中进行引用
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>第一个js程序</title>
    <!--引入外部js文件-->
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript">
        //继续在这里去写
    </script>
</head>
<body>
<input type="button"   value="测试">
</body>
</html>
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号