Javascript examples for DOM:Element addEventListener
Listen to the events inside an object
<html> <head></head> <body> <div id="button1"> Button-1 </div> <script> var object1 = { button1: document.getElementById('button1'), eventHandler: function() {// www .j a va 2 s . co m this.button1.addEventListener('click', this.alertSomething); }, alertSomething: function() { console.log('Cool'); } }; object1.eventHandler.call(object1); </script> </body> </html>