您的位置:首页 > Web前端 > HTML

【html】设置有滚动条的select

2017-05-09 08:24 274 查看
问题提出:select默认的会将所有的option全部显示出来,当数据过多时,下拉框会显得很长。

期待结果:带有滚动条,显示一定数量的option,通过滚动查看更多option。

效果展示:



源码:

<select class='newsTypeList' onfocus="selectFocus(this)">  
<option onclick="selectClick(this)">1</option>  
</select>
window.selectFocus = function(that) {  
$(that).attr("size", 5);  
};  
window.selectClick = function(that) {  
$(that).parent().removeAttr("size");  
$(that).parent().blur();  
$(that).parent().children("[selected='selected']").removeAttr("selected");  
$(that).attr("selected", "");  
};  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  滚动条 html