如何将js与HTML完全脱离

先举出一个例子:

1 var sound='Roar!';
2 function myOrneryBeast(){
3     alert(this);
4     this.style.color='green';//this指代的是window对象
5     alert(sound);
6 }
7 window.onload=function(){
8     document.getElementById("a").onclick=myOrneryBeast;//将HTML中的点击事件移到js中了
9 }
原文地址:https://www.cnblogs.com/xs-yqz/p/4273015.html