what's the equivalent of jQuery's trigger
method without jQuery?
e.g., how do i do something like $('.blah').trigger('click');
without jQuery?
event.initMouseEvent("click"...
Here is an example:
function simulateClick(elId) { var evt; var el = document.getElementById(elId); if (document.createEvent) { evt = document.createEvent("MouseEvents"); evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); } (evt) ? el.dispatchEvent(evt) : (el.click && el.click()); } var foo = document.getElementById("hey"); foo.onclick = function () {alert("bar");} simulateClick("hey");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With