html select下拉菜单长度过长不出滚动条问题解决办法


  
<select class="form-control"  data-edit-select="1"  onmousedown="selectmousedown(this)" 
onblur="selectblur(this)" onchange="selectchange(this)"
style="position:absolute;z-index:120">
</select>
function selectmousedown(ev) {
    if (ev.options.length > 5) {
        ev.size = 6;
        $(ev).css({
            "height": "auto",
            "position": "absolute"
        })
    } else {
        $(ev).css("height", "28px")
    }
}

function selectblur(ev) {
    ev.size = 0;
    $(ev).css({
        "height": "28px",
        "position": "static"
    })
}

function selectchange(ev) {

    ev.size = 0;
    $(ev).css({
        "height": "28px",
        "position": "static"
    })
}

  

结果如图:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM