JavaScript - 强制选择要下拉的元素? [英] JavaScript - Force select element to dropdown?
本文介绍了JavaScript - 强制选择要下拉的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Javascipt强制select元素下拉?可以吗?
How can I force the select element to dropdown using Javascipt? Is it possible?
<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 ...
where id is the id of the your select box...
这篇关于JavaScript - 强制选择要下拉的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文