本文介绍了如何限制HTML< select>中的可见选项落下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何限制HTML < select>
下拉列表中显示的选项数?
How can I limit the number of shown options in an HTML <select>
drop down?
例如:
<select>
<option value="1">1</option>
<option value="2">2</option>
...
<option value="20">20</option>
</select>
如何让浏览器只显示前五个选项,向下滚动剩下的? / p>
How can I get the browser to show only the first five options and scroll down for the rest?
推荐答案
你可以尝试这个
<select name="select1" onmousedown="if(this.options.length>8){this.size=8;}" onchange='this.size=0;' onblur="this.size=0;">
<option value="1">This is select number 1</option>
<option value="2">This is select number 2</option>
<option value="3">This is select number 3</option>
<option value="4">This is select number 4</option>
<option value="5">This is select number 5</option>
<option value="6">This is select number 6</option>
<option value="7">This is select number 7</option>
<option value="8">This is select number 8</option>
<option value="9">This is select number 9</option>
<option value="10">This is select number 10</option>
<option value="11">This is select number 11</option>
<option value="12">This is select number 12</option>
</select>
它为我工作
这篇关于如何限制HTML< select>中的可见选项落下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!