这应该工作:
$('option').hide(); // hide options
它可以在Firefox中运行,但不能在Chrome中运行(可能未在IE中运行,未经测试)。
一个更有趣的示例:
<select>
<option class="hide">Hide me</option>
<option>visible option</option>
</select>
<script type="text/javascript">
// try to hide the first option
$('option.hide').hide();
// to select the first visible option
$('option:visible').first().attr('selected', 'selected');
</script>
或参见http://jsfiddle.net/TGxUf/上的示例
是将选项元素与DOM分离的唯一选择吗?我需要稍后再显示给他们,所以这不会很有效。
qq_笑_17
相关分类