Skip to content

Instantly share code, notes, and snippets.

@benubois
Created March 16, 2010 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benubois/334214 to your computer and use it in GitHub Desktop.
Save benubois/334214 to your computer and use it in GitHub Desktop.
// Simulate a click event on the matched id
HTMLElement.prototype.click = function()
{
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}
document.getElementById("id").click();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment