1.行間事件
onclick="函數名()";
<div id="div1" onmouseover="over('400px','400px','green')" onmouseout="over('200px','200px','red')"
onclick="show()"></div>
2.js中加事件 設置函數,發生事件時才觸發
匿名函數
obj.onmouseout=function(){
//此處可用this 應為obj調用者已確定
this.style.width="400px";
this.style['background-color']="green";
}
obj.onmouseover=function(){
this.style.width="200px";
this.style['background-color']="red";
};
js中加事件 非匿名函數 onclick=函數名;
function s(){
....
}
obj.onclick=s;
