+ 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?
3 Answers
+ 4
button.addEventListener('click', function(){
// if you're here, the button has been clicked.
});
+ 2
Vladimir, I've tried dat before but it didn't work
0
button.onclick = function(){
// if you're here, the button has been clicked.
};
Try it yourself: https://code.sololearn.com/WSNNfNTSWxS3