jquery ui内autocomplete中的combobox如何设置下拉层高度

现在此下拉层高度是自适应,有多少数据就列多长。想怎么设置高度,让多余的数据用滚动跳查看。

给你找的源码 有这个效果的 max-height

<!DOCTYPE html>



jQuery UI Autocomplete - Scrollable results







<br> .ui-autocomplete {<br> max-height: 100px;<br> overflow-y: auto;<br> /* prevent horizontal scrollbar <em>/<br> overflow-x: hidden;<br> /</em> add padding to account for vertical scrollbar <em>/<br> padding-right: 20px;<br> }<br> /</em> IE 6 doesn&#39;t support max-height<br> * we use height instead, but this forces the menu to always be this tall<br> */<br> * html .ui-autocomplete {<br> height: 100px;<br> }<br>
<br> $(function() {<br> var availableTags = [<br> &quot;ActionScript&quot;,<br> &quot;AppleScript&quot;,<br> &quot;Asp&quot;,<br> &quot;BASIC&quot;,<br> &quot;C&quot;,<br> &quot;C++&quot;,<br> &quot;Clojure&quot;,<br> &quot;COBOL&quot;,<br> &quot;ColdFusion&quot;,<br> &quot;Erlang&quot;,<br> &quot;Fortran&quot;,<br> &quot;Groovy&quot;,<br> &quot;Haskell&quot;,<br> &quot;Java&quot;,<br> &quot;JavaScript&quot;,<br> &quot;Lisp&quot;,<br> &quot;Perl&quot;,<br> &quot;PHP&quot;,<br> &quot;Python&quot;,<br> &quot;Ruby&quot;,<br> &quot;Scala&quot;,<br> &quot;Scheme&quot;<br> ];<br> $( &quot;#tags&quot; ).autocomplete({<br> source: availableTags<br> });<br> });<br>

Tags:

<!-- End demo -->

When displaying a long list of options, you can simply set the max-height for the autocomplete menu to prevent the menu from growing too large. Try typing "a" or "s" above to get a long list of results that you can scroll through.

<!-- End demo-description -->


好像没有很好的办法,用div模拟把

下面的一个例子也是比较丑

<select heigth="20px;" onclick="click();" id="select1" onblur="event()"

onchange="event()">
1
2
3
4
5
6
7
8
9
10

function click(){ document.getElementById("select1").size="2"; } function event(){ document.getElementById("select1").size="1"; }