Joined February 2014
·
Posted to
Getting a list of your eventListeners so you can trigger it programmatically
over 1 year
ago
Nice article, but to trigger registered events programatically on any DOM element, you can use the EventTarget.dispatchEvent method, like for example:
btn=document.getElementById('buttonx');
btn.dispatchEvent(new MouseEvent('click')); // this will make any click event listener on the button to be invoked
you can also use (new Event('click') simply)
But what you have said in this article still usefull if you want to see the list of event listeners. may be for debugging purpose.
This is much better than Ctrl-R. Thank you very much..