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 :)
精彩评论