Latest web development tutorials

HTML DOM tr 對象

tr 對象

tr 對象代表了HTML 表格的行。

HTML文檔中出現一個<tr> 標籤,就會創建一個tr對象。


tr 對象集合

W3C: W3C標籤。

集合 描述 W3C
cells 返回表格行中所有<td>和<th>元素的集合 Yes

tr 對象屬性

属性 描述 W3C
align 已废弃。 设置或返回在行中数据的水平排列。 D
bgColor 已废弃。 设置或返回表格行的的颜色。 D
ch 设置或返回在行中单元格的对齐字符。 Yes
chOff 设置或返回在行中单元格的对齐字符的偏移量。 Yes
height 已废弃。设置或返回表格行的高度。使用 style.height 取代 D
rowIndex 返回该行在表中的位置。 Yes
sectionRowIndex R返回在 tBody 、tHead 或 tFoot 中,行的位置。 Yes
vAlign 设置或返回在行中的数据的垂直排列方式。 Yes

tr 對象方法

方法 描述 W3C
deleteCell() 删除行中的指定的单元格。 Yes
insertCell() 在一行中的指定位置插入一个空的元素。 Yes

標準屬性和事件

tr對象同樣支持標準的屬性事件