1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>练习</title>
6 <script type="text/javascript" src="learn.js">
7 //document.write('js练习。');//分号;可省。1.可写在body里;2.可写在head里;3.可从外部引入js文件。
8 </script>
9 </head>
10 <body>
11 <input type="button" name="js练习" value="普通按钮" onclick="alert('从零开始')">
12 </body>
13 </html>
1 document.write('从js文件中引入。')
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>练习</title>
6 <script type="text/javascript" src="learn.js">
7 //document.write('js练习。');//分号;可省。1.可写在body里;2.可写在head里;3.可从外部引入js文件。
8 </script>
9 </head>
10 <body>
11 <input type="button" name="js练习" value="普通按钮" onclick="alert('从零开始')">
12 <script type="text/javascript">
13 document.write('普通文本,<h1>h1标题</h1>这里会换行;<br>再一个换行;<br/> <ul><li>列表1</li><li>列表2</li></ul>');
14 alert('直接弹出');
15 </script>
16 </body>
17 </html>
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>练习</title>
6 </head>
7 <body>
8 <script type="text/javascript">
9 var x=10;
10 var y;
11 y=11;
12 // alert(x);
13 // alert(y);
14 var a=10,b=20,c=30;
15 // alert(a+b+c);
16 </script>
17 <script type="text/javascript">
18 document.write("a+b+c="+(a+b+c));
19 </script>
20 </body>
21 </html>