先举出一个例子:
1 var sound='Roar!'; 2 function myOrneryBeast(){ 3 alert(this); 4 this.style.color='green';//this指代的是window对象 5 alert(sound); 6 } 7 window.οnlοad=function(){ 8 document.getElementById("a").οnclick=myOrneryBeast;//将HTML中的点击事件移到js中了 9 }
先举出一个例子:
1 var sound='Roar!'; 2 function myOrneryBeast(){ 3 alert(this); 4 this.style.color='green';//this指代的是window对象 5 alert(sound); 6 } 7 window.οnlοad=function(){ 8 document.getElementById("a").οnclick=myOrneryBeast;//将HTML中的点击事件移到js中了 9 }
转载于:https://www.cnblogs.com/xs-yqz/p/4273015.html