Use of the dynamic binding event addEventListener method
- 2020-03-30 01:29:21
- OfStack
<script language = "javascript" type = "text/javascript">
function test(){
window.alert(" You voted once ");
//Unbound event
document.getElementById("but1").removeEventListener("onclick",test);
}
</script>
<body>
<input id = "but1" type = "button" value = " vote " />
<script language = "javascript" type = "text/javascript">
//Dynamically bound events can be unbound
document.getElementById("but1").addEventListener("onclick",test);
</script>
</body>