看板 Web_Design 關於我們 聯絡資訊
請教一下,我底下的code在firefox下運作正常,但在ie出了問題。 問題有兩個: (1)若只有setAttribute("name","rdo"),ie取物件的時候會出狀況。 document.getElementsByName("rdo").length為0,加上青色那行,則為2。 好笑的是給id還要用getElementsByName才抓得到,getElementById會出錯。 (PS:firefox不用加青色那行就ok了) (2)這問題更嚴重,畫面上的確長出兩個radio,可是不能點選。 就是滑鼠點了也沒用,radio不會變成checked的狀態,也不會觸發onclick() 這問題有辦法解嗎?快把我搞死了 -_-# var tableObj = document.getElementById("tbl"); var nextRow = tableObj.tBodies[0].rows.length; var row = tableObj.tBodies[0].insertRow(nextRow); var cell0 = row.insertCell(0); var input1 = document.createElement("input"); input1.setAttribute("type", "radio"); input1.setAttribute("name", "rdo"); input1.setAttribute("id", "rdo"); var input2 = document.createElement("input"); input2.setAttribute("type", "radio"); input2.setAttribute("name", "rdo"); input2.setAttribute("id", "rdo"); cell0.appendChild(input1); cell0.appendChild(input2); //alert(document.getElementsByName("rdo").length); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.112.133.13 ※ 編輯: ckw 來自: 59.112.133.13 (05/25 15:18)
ckw:補充一點,setAttribute("checked","true")在ie中也無效 @_@ 05/25 15:29
TonyQ:看一看 #15iX4uQt 05/25 17:48
ckw:感謝TonyQ大力協助,總算搞定了 05/25 18:16