+ 3
WHY Event is occurring itself in javascript......
it should work when i click on button but it's working automatically...... this is code.... <script> document.getElementById('idofbutton').addEventListener('click', alert('hey'));
3 Antworten
+ 1
this is because alert("hey") gets executed when evaluating the argument. Put it inside a function, as follows:
addeventlistener('click',function() {alert("hey")})
+ 3
ok i will try....
+ 3
thanks bro 😀