Last active
October 10, 2018 20:33
-
-
Save jcsrb/d8bb6e3c0ba7ad401808 to your computer and use it in GitHub Desktop.
How open a <select> element programmatically
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
//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"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looked promising but doesn't work as far as I can tell on chrome.