Can I open a dropdownlist using jQuery

后端 未结 14 1715
终归单人心
终归单人心 2020-11-22 09:49

For this dropdownlist in HTML:


I would lik

14条回答
  •  天命终不由人
    2020-11-22 09:59

    I tried using mrperfect's answer and i had a couple glitches. With a couple small changes, I was able to get it to work for me. I just changed it so that it would only do it once. Once you exit dropdown, it would go back to the regular method of dropdowns.

    function down() {
        var pos = $(this).offset(); // remember position
        $(this).css("position", "absolute");
        $(this).offset(pos);   // reset position
        $(this).attr("size", "15"); // open dropdown
        $(this).unbind("focus", down);
    }
    function up() {
        $(this).css("position", "static");
        $(this).attr("size", "1");  // close dropdown
        $(this).unbind("change", up);
    }
    function openDropdown(elementId) {
        $('#' + elementId).focus(down).blur(up).focus();
    }
    

提交回复
热议问题