<div class="codetitle"> <span><a style="CURSOR: pointer" data="18101" class="copybut" id="copybut18101" onclick="doCopy('code18101')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code18101"> <br><script language="javascript" type="text/javascript"> <BR>function test(){ <BR>window.alert("你投了一次票"); <BR>//解除绑定事件 <BR>document.getElementById("but1").removeEventListener("onclick",test); <BR>} <BR></script> <br> <br><input id="but1" type="button" value="投票"> <br><script language="javascript" type="text/javascript"> <BR>//动态绑定事件 可以取消绑定 <BR>document.getElementById("but1").addEventListener("onclick",test); <BR></script> <br> <br> </div> <br><img src="http://files.jb51.net/file_images/article/201401/201401241518151.gif?2014024151842" alt="动态的绑定事件addEventListener方法的使用_javascript技巧" >