如何使用Javascript强制select元素下拉?可能吗?
<select id="MiamiPlayers">
<option value="0">Bosh</option>
<option value="1">Wade</option>
<option value="2">LeBron</option>
</select>
<input type="button" onclick="Show()" />
<script type="text/javascript">
function Show()
{
//force the select to dropdown...
}
</script>
提前致谢!
var select = document.getElementById(id);
select.size = select.options.length;
其中id是您选择框的ID ...
你不能打开下拉菜单,但你可以这样做:
document.getElementById('MiamiPlayers').setAttribute('size', 3);