如何用程式碼彈出Select框
阿新 • • 發佈:2018-11-05
不適用所有瀏覽器,經測試支援Chrome,IOS上的SAFARI
("#觸發點").click(function(e) {
var element = $("#下拉框")[0], worked = false;
if (document.createEvent) { // all browsers
var e = document.createEvent("MouseEvents");
e.initMouseEvent("mousedown", true, true, window, 0 , 0, 0, 0, 0, false, false, false, false, 0, null);
worked = element.dispatchEvent(e);
} else if (element.fireEvent) { // ie
worked = element.fireEvent("onmousedown");
}
if (!worked) { // unknown browser / error
alert("It didn't worked in your browser." );
}
});