变量和字符串的区别

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <meta charset="utf-8">
 5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 6 <title>练习</title>
 7 <style type="text/css">
 8 #box{width: 300px;height: 300px;background: yellow;margin:10px auto;}    
 9 </style>
10 </head>
11 <body>
12     <input type="button" value="点击" onclick="alert('1')";>
13     <input type="button" value="点击2" onclick="alert(2)";>
14     <input type="button" value="点击3" onclick="alert(1+2)";>
15     <input type="button" value="点击4" onclick="alert('1'+'2')";>
16     <input type="button" value="点击5" onclick="alert('1'+2)";>
17     
18     <input type="button" value="点击6" onclick="alert(我)";>
19     <input type="button" value="点击7" onclick="alert('我')";>
20 </body>
21 </html>

alert中带引号的是字符串,不带引号的是变量,变量必须先定义,所以,不带引号的我,将无法弹出来

posted on 2015-07-20 18:36  zhangjingyun  阅读(505)  评论(0编辑  收藏  举报