<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技巧" >