开发者

Dynamically increase the size of a multi select drop down box

I've implemented this on mouseover and onmouseout like so:

开发者_如何学Python
<select size="3" onmouseover="this.size=this.options.length;">

This is all well and good, except i don't want it only on mouseover, i want it always :) forever.

Thanks in advance.


Update it on DomReady.

window.onDomReady = function() {
    var a = document.getElementById('yourId');
    a.size = a.length;
}


<select size="3" onmouseover="this.size=this.length;">
    <option>hello world 1</option>
    <option>hello world 2</option>
    <option>hello world 3</option>
    <option>hello world 4</option>
    <option>hello world 5</option>
    <option>hello world 6</option>
    <option>hello world 7</option>
    <option>hello world 8</option>
</select>

this worked for me :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜