相关疑难解决方法(0)

style.display ='none'对chrome中的选项标签不起作用,但它在firefox中有效

好的,下面是一些演示问题的示例代码.如果我点击Firefox中的按钮,第一个选项就会消失.如果我点击chrome中的按钮,没有任何反应,或者更确切地说,如果我检查第一个选项,它确实具有属性"style ='display:none'",但html页面上的选项本身并未隐藏.

<form>
<select>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<input type="button" onclick="document.getElementsByTagName('option')[0].style.display='none'" value="hide option 1">
</form>
Run Code Online (Sandbox Code Playgroud)

为什么这不适用于chrome?

javascript firefox coding-style google-chrome

35
推荐指数
2
解决办法
6万
查看次数

标签 统计

coding-style ×1

firefox ×1

google-chrome ×1

javascript ×1