Skip to content

Instantly share code, notes, and snippets.

@jcsrb
Last active October 10, 2018 20:33
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcsrb/d8bb6e3c0ba7ad401808 to your computer and use it in GitHub Desktop.
Save jcsrb/d8bb6e3c0ba7ad401808 to your computer and use it in GitHub Desktop.
How open a <select> element programmatically
//Thank to @Formstone https://github.com/Formstone/Selecter/blob/master/src/jquery.fs.selecter.js
if (window.document.createEvent) { // All
var evt = window.document.createEvent("MouseEvents");
evt.initMouseEvent("mousedown", false, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
el.dispatchEvent(evt);
} else if (el.fireEvent) { // IE
el.fireEvent("onmousedown");
}
@PeterKottas
Copy link

Looked promising but doesn't work as far as I can tell on chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment