Skip to content

Instantly share code, notes, and snippets.

@yoeun
Last active December 8, 2016 22:35
Show Gist options
  • Select an option

  • Save yoeun/3499725953ba1321c41550b7d7f1d97f to your computer and use it in GitHub Desktop.

Select an option

Save yoeun/3499725953ba1321c41550b7d7f1d97f to your computer and use it in GitHub Desktop.
Manual mouse event using document.createEvent() and element.dispatchEvent()
// modern
var evt = new Event("mouseup", {"bubbles":true, "cancelable":true});
document.querySelector(".foo-bar").dispatchEvent(evt);
// deprecated
var evt = document.createEvent("MouseEvents");
evt.initEvent("mouseup", true, true);
document.querySelector(".foo-bar").dispatchEvent(evt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment