Table的两个属性rowIndex与cellIndex
来源:互联网 发布:利用大数据相关案例 编辑:程序博客网 时间:2024/05/23 18:31
HTML DOM rowIndex属性
功能:返回表格中行的序号。
语法:object.rowIndex
说明:该属性只读。
rowIndex用于判断当前单元格所处行的索引(从0开始)
实例1
获取指定行在表格中的序号。
<table width="80%" border="1" cellpadding="0" cellspacing="0" bordercolor="blue">
<thead>
<tr><td>1</td><td>2</td></tr>
</thead>
<tbody>
<tr id="rr"><td>3</td><td>4</td></tr>
<tr><td>5</td><td>6</td></tr>
</tbody>
</table>
<div>
<script type="text/javascript">
document.write( document.getElementById("rr").rowIndex );
</script>
</div>
通常我们可以把他们的事件写在TD里,因为rowIndex属性应该是属于<tr>标记,因此在判断rowIndex需要访问父节点,
<script type="text/javascript">
function demo(elem){
var tr = elem.parentNode;
alert(tr.rowIndex);
}
</script>
<table>
<tr>
<td></td>
<td onclick="demo(this);">edit</td>
</tr>
<tr>
<td></td>
<td onclick="demo(this);">edit</td>
</tr>
</table>
cellIndex属性
功能:返回单元格在行中的位置。
语法:object.cellIndex
说明:该属性只读。
cellIndex用于判断当前单元格所处列的索引(从0开始)
实例2
获取指定单元格在行中的位置。
<table id="mytable" width="80%" border="1" cellpadding="0" cellspacing="0" bordercolor="blue">
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td id="tt">6</td></tr>
<tr><td>7</td><td>8</td><td>9</td></tr>
</table>
<div>
<script type="text/javascript">
document.write( document.getElementById("tt").cellIndex );
</script>
</div>
rowIndex属性的值是行在表格中总的位置,包含了thead、tbody、tfoot各个区域。
- Table的两个属性rowIndex与cellIndex
- Table的两个属性rowIndex与cellIndex
- Table的两个属性rowIndex与cellIndex
- Table的两个属性rowIndex与cellIndex
- Table的两个属性rowIndex与cellIndex
- table的 rowIndex 属性
- node,tag,parentNode,parentElement,cells,rows,cellIndex,rowIndex,sectionRowIndex......
- HTML DOM rowIndex 属性
- table的属性与js即时获取table属性问题
- table的RULES属性
- table的border属性
- TABLE的logging属性
- Table的title属性
- table标签的属性
- 两个清爽的table样式
- window.event.srcElement.parentElement.parentElement.rowIndex;与r.parentNode.parentNode.rowIndex
- GCC的两个属性
- input的两个属性
- 有关getAttribute()方法和setAttribute()方法的说明
- 做最真的自己
- JFreeChart教程
- windbg c++ sample
- js 中有关toFixed的用法
- Table的两个属性rowIndex与cellIndex
- event.cancelBubble的理解
- 有关框架左右同时滚动效果。
- 微软企业库5.0学习笔记(六)创建并引用企业库对象
- 用两种方式创建Table
- 一个GDI资源泄漏检测程序
- iframe中如何插入html
- 鼠标经过改变表格背景属性实例
- 个人开公司的流程,以后用得着