Last active
April 14, 2018 20:35
-
-
Save ThinkDigitalSoftware/3fa2107e6ed9913ad5260b79bd9c5ed7 to your computer and use it in GitHub Desktop.
Simulate a click on a Javascript Element. Credit goes to KooiInc, https://stackoverflow.com/a/2706236/2880055
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function eventFire(el, etype){ | |
//Usage: eventFire(document.getElementById('mytest1'), 'click'); | |
if (el.fireEvent) { | |
el.fireEvent('on' + etype); | |
} else { | |
var evObj = document.createEvent('Events'); | |
evObj.initEvent(etype, true, false); | |
el.dispatchEvent(evObj); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment