亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

style.display ='none'對chrome中的選項標簽不起作用

style.display ='none'對chrome中的選項標簽不起作用

慕村9548890 2019-08-19 17:18:20
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>為什么這不適用于chrome?
查看完整描述

3 回答

?
SMILET

TA貢獻1796條經驗 獲得超4個贊

你可能不得不刪除<option>而不是“隱藏”它。如果它不適合您,請嘗試禁用它。

document.getElementsByTagName('option')[0].disabled='disabled'

PS:您可能想重新考慮使用getElementsByTagName('option'),如果您有更多<select>元素,可能會變得混亂。


查看完整回答
反對 回復 2019-08-19
  • 3 回答
  • 0 關注
  • 1682 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號