开发者

Dynamically increase the size of a multi select drop down box

开发者 https://www.devze.com 2023-01-17 14:45 出处:网络
I\'ve implemented this on mouseover and onmouseout like so:开发者_如何学Python <select size=\"3\" onmouseover=\"this.size=this.options.length;\">

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

精彩评论

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