を「フォーカス」を試すことができます「をクリックし、」あなたはopenSelect()
にCSSセレクタを通過し、 select
要素が表示されます。ここで
var openSelect = function(selector){
var element = $(selector)[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.");
}
}
$(function(){ // when DOM is ready
// open .select element
openSelect('.select');
});
はフィドルです:http://jsfiddle.net/Z48wF/1/
出典:私は、単一のソリューションがあるとは思わないHow can you programmatically tell an HTML SELECT to drop down (for example, due to mouseover)?
:stackoverflow.com
可能な重複:http://stackoverflow.com/questions/2048213/open-select-using-javascript-jquery – Kenneth
チェックアウトのhttp://api.jqueryui .com/selectmenu /#method-open –