日期:2014-05-16 浏览次数:20372 次
2011-03-24 13:41:23|??分类:?默认分类?|??标签:无|字号?订阅【引用】js中firefox,ie兼容
? var tbl = document.getElementById("aclTbl"); (通过id获得table)?
? //插入一行
? var rowsLen = tbl.rows.length;
? var row = tbl.insertRow(rowsLen);
? aa. firefox写法:
?????var chkbox = document.createElement("input");
???? chkbox.type = "checkbox";
?? ? chkbox.name = "checkbox_index";
???? chkbox.value = rowsLen;
???? cell = row.insertCell(0);
???? cell.appendChild(chkbox);
???? row.appendChild(cell);?
? bb. ie写法:
????var chkbox = document.createElement("<input type='checkbox' name='checkbox_index' value='" + rowsLen +?? "'/>");??
??? cell = row.insertCell(0);
??? cell.appendChild(chkbox);
??? row.appendChild(cell);
?cc. 兼容写法:
????var chkbox= document.createElement("td");
??? chkbox.innerHTML = "<input type='checkbox' name='checkbox_index' value='" + rowsLen + "'/>";
??? cell = row.insertCell(0);
??? cell.appendChild(chkbox);
??? row.appendChild(cell);?
2.动态修改表格本内容
?? tbl.rows[row_index].cells(1).innerHTML