Created
November 10, 2015 03:27
-
-
Save hyhoocchan/6c9fec9e383cc2790e0a to your computer and use it in GitHub Desktop.
Trigger Event Prototype by jQuery
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
| Element.prototype.triggerEvent = function(eventName) | |
| { | |
| if (document.createEvent) | |
| { | |
| var evt = document.createEvent('HTMLEvents'); | |
| evt.initEvent(eventName, true, true); | |
| return this.dispatchEvent(evt); | |
| } | |
| if (this.fireEvent) | |
| return this.fireEvent('on' + eventName); | |
| }; | |
| jQuery('element id').triggerEvent('click'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment