好看吧
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script src="JS/jquery-1.4.1.js" language="JavaScript"></script> <script type="text/javascript" language="JavaScript"> var foo = { bar: function() { alert(this); } }; function test (){ this.a=1; var f=function(){ alert("你是个大聪明啊"); } } var t=new test(); alert(t.prototype); alert(t.a); function btnClick() { alert(this); var a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; a.forEach(function pri(element, index, arr) { if (element % 2 == 0) alert(element + "我是一个偶数"); else { alert(element + "我是一个非偶数"); } }); } </script> </head> <body> <button id="btnOk" type="button" onclick="btnClick();return false;">点击我测试数据</button> <p id="p1">1</p> <p id="p2">2</p> </body> </html>