Skip to content

Instantly share code, notes, and snippets.

@crccheck
Created February 14, 2011 00:12
Show Gist options
  • Save crccheck/825327 to your computer and use it in GitHub Desktop.
Save crccheck/825327 to your computer and use it in GitHub Desktop.
jQuery.fn.simulateClick = function() {
// simulate a mouse click, only acts on the first element of a set
if (this.length) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
this[0].dispatchEvent(evt);
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment