[討論] removeAttr, selected, IE bug?

看板Ajax作者 (for pete's sake)時間16年前 (2009/05/23 16:07), 編輯推噓0(004)
留言4則, 2人參與, 最新討論串1/3 (看更多)
IE似乎沒辦法消滅selected (以及disabled) 也就是在IE環境下 無法讓以下的黃色字消失 <option value="1" class="option_1" selected="selected">1</option> 而且selected的值似乎只能是selected或true 沒有none, no這類的選項 我只是來討論我的發現 不期待有什麼解法 我寫的code如下 //both work fine except IE //1.DOM solution, but IE doesn't act well //getElementsByClassName("option_1").removeAttribute("selected"); //2.jquery, but not cross IE browser $(".option_1").removeAttr("selected"); 網路上有許多類似的問題,例如: http://gimp4you.eu.org/sandbox/js/test/removeAttr.html http://bbs.jquery.org.cn/read.php?tid-830-fpage-86.html http://www.mail-archive.com/jquery-en@googlegroups.com/msg04018.html -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.40.183 ※ 編輯: tomin 來自: 122.116.40.183 (05/23 16:12)

05/23 16:19, , 1F
想要移除selected的目的是?
05/23 16:19, 1F
我原本要達到的目標是排優先順序 比如說有三個select 1 2 3 飛機 1 2 3  火車 1 2 3 公車 1,2,3不能重覆 移除selected 我是用來移除重覆的選項 比如火車選1後 飛機又再選1 要將火車的1移除 ※ 編輯: tomin 來自: 122.116.40.183 (05/23 18:17)

05/23 18:22, , 2F
唔 , 是真的要把 option remove 掉 , 還是改 selectIndex ?
05/23 18:22, 2F

05/23 18:22, , 3F
你說的需求感覺不需要特地繞遠路去移除 selected 欸 o_oa
05/23 18:22, 3F

05/23 18:27, , 4F
只要改selectIndex option可以remove 是attr才remove不掉
05/23 18:27, 4F
文章代碼(AID): #1A5wwqL- (Ajax)
文章代碼(AID): #1A5wwqL- (Ajax)