<TABLE id=tbl cellSpacing=1 cellPadding=1 border=1>
<TBODY>
<TR>
<TD width=100>This is Line1</TD></TR>
<TR>
<TD width=100>This is Line2</TD></TR>
<TR>
<TD width=100 onclick="alert(this.parentElement.cellIndex)">This is Line3</TD></TR>
</TBODY>
</TABLE>
<TBODY>
<TR>
<TD width=100>This is Line1</TD></TR>
<TR>
<TD width=100>This is Line2</TD></TR>
<TR>
<TD width=100 onclick="alert(this.parentElement.cellIndex)">This is Line3</TD></TR>
</TBODY>
</TABLE>
写错了
<TABLE id=tbl cellSpacing=1 cellPadding=1 border=1>
<TBODY>
<TR>
<TD width=100>This is Line1</TD></TR>
<TR>
<TD width=100>This is Line2</TD></TR>
<TR>
<TD width=100 onclick="alert(this.cellIndex)">This is Line3</TD></TR>
</TBODY>
</TABLE>
obj.cellIndex是列号
在请问大家一下,为什么用,obj.focus()获得焦点时,文本框中的内容不会被选中,请问如何处理后才能让它被选中。
谢谢!
-----------------<input type="text" onfocus="this.select()" value="灰豆宝宝.net">
列总数能直接得到吗?
还是要通过the_table.cells.length和the_table.rows.length来计算?
好象是不能用the_table.cols.length.
谢谢!
<tr><td>Click and look statusBar</td><td>Click and look statusBar</td><td>Click and look statusBar</td></tr>
<tr><td>Click and look statusBar</td><td>Click and look statusBar</td><td>Click and look statusBar</td></tr>
<tr><td>Click and look statusBar</td><td>Click and look statusBar</td><td>Click and look statusBar</td></tr>
<tr><td>Click and look statusBar</td><td>Click and look statusBar</td><td>Click and look statusBar</td></tr>
<tr><td>Click and look statusBar</td><td>Click and look statusBar</td><td>Click and look statusBar</td></tr>
</table>
<script>
function document.onclick(){
var e=window.event.srcElement
if(e.tagName=="TD"){
window.status="第"+(e.parentElement.rowIndex+1)+"行,第"+(e.cellIndex+1)+"列"
}
}
</script>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</table>
<tr>
<td colspan=2>12</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</table>
<script>
function getColsLength(tbObj){
var count=tbObj.rows[0].cells.length;
for(var i=0;i<tbObj.rows[0].cells.length;i++){
count+=parseInt(tbObj.rows[0].cells[i].colSpan,10)-1;
}
return count;
}
</script>