方法一:
var btn = document.getElementById("btn");
btn.onclick=function(){
alert("hello world");
}
消除事件:btn.onclick=null;
方法二:
var btn = document.getElementById("btn");
btn.addEventListener('click',function(){
alert("hello wrold");
},false)
方法三:
function test(){
alert("hello world");
}