东成熙就 2014-01-24
代码如下:
<script language = "javascript" type = "text/javascript"> function test(){ window.alert("你投了一次票"); //解除绑定事件 document.getElementById("but1").removeEventListener("onclick",test); } </script> <body> <input id = "but1" type = "button" value = "投票" /> <script language = "javascript" type = "text/javascript"> //动态绑定事件 可以取消绑定 document.getElementById("but1").addEventListener("onclick",test); </script> </body>