1 2 3 4 |
var el = document.getElementById('YourElementID'); var e = document.createEvent("MouseEvents"); e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); el.dispatchEvent(e); |
This often comes up, when you work with jQuery and try to do a simple $(“#YourElementID”).trigger(“click”); or similar.