Created
September 21, 2011 16:14
-
-
Save avhm/1232502 to your computer and use it in GitHub Desktop.
Simulate Mouse Click
This file contains 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 simulateMouseClick(selector) { | |
var targets = document.querySelectorAll(selector), | |
evt = document.createEvent('MouseEvents'), | |
i, len; | |
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); | |
for ( i = 0, len = targets.length; i < len; ++i ) { | |
targets[i].dispatchEvent(evt); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment