Created
September 2, 2014 06:21
-
-
Save sshmyg/9c4cdf798e482c18a77c to your computer and use it in GitHub Desktop.
Trigger DOM event
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
/** | |
* @param target can be any DOM Element or other EventTarget | |
* @param type Event type (i.e. 'click') | |
*/ | |
var trigger = function (target, type) { | |
if (document.createEvent) { | |
event = new Event(type); | |
target.dispatchEvent(event); | |
} else { | |
event = document.createEventObject(); | |
target.fireEvent('on' + type, event); | |
} | |
}; | |
//trigger(element, 'click'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment