它是什么,我做错了这里:未定义id属性
当我尝试使用getttribute [“身份证”]方法的TableCell的对象,我从得到通过遍历表行/细胞则返回undefined:
var rows = document.getElementById["table"].rows;
var cells;
for(var i=0; i < rows.length; i++) {
cells = rows[i].cells
for(var j=0; j < cells.length; j++) {
alert(cells[j].innerHTML); //returns Cell1
alert(cells[j].getAttribute["id"]); //returns undefined
alert(document.getElementById["c1"].innerHTML); //returns Cell1
}
}
这是例如HTML:
<table id="table">
<tbody>
<tr>
<td id="c1">Cell1</td>
</tr>
</tbody>
</table>
问题是为什么没有定义的所有属性磨片getAttribute方法返回n通过单元格[j]访问?
是的,这是真的,这是一种方法!谢谢 – 2010-03-10 06:29:33