+ 4

How can I listen to events on DOM objects in javascript.

e. g var button = createElement("button); how can I listen to onclick event on button object?

30th Nov 2016, 9:01 PM
damilare lamidi
damilare lamidi - avatar
3 Antworten
+ 4
button.addEventListener('click', function(){ // if you're here, the button has been clicked. });
30th Nov 2016, 9:05 PM
Schindlabua
Schindlabua - avatar
+ 2
Vladimir, I've tried dat before but it didn't work
30th Nov 2016, 9:30 PM
damilare lamidi
damilare lamidi - avatar
0
button.onclick = function(){ // if you're here, the button has been clicked. }; Try it yourself: https://code.sololearn.com/WSNNfNTSWxS3
30th Nov 2016, 10:55 PM
Vladimir Honcharenko
Vladimir Honcharenko - avatar