stefanbc
1/22/2015 - 11:27 AM

How open a <select> element programmatically

How open a 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");
}