Latest web development tutorials

HTML DOM 표 행 컬렉션

테이블 객체 참조 표 개체

정의 및 사용

HTMLCollection 것으로, 테이블 행 컬렉션 모든 행 (TableRow 객체)의 배열을 돌려줍니다.

세트가 포함 된 <THEAD>, <TFOOT>와 <TBODY> 모든 행이 정의되어있다.

문법

tableObject.rows

재산

属性 描述
length 返回集合中 <tr> 元素的数目

방법

Method 描述
[name_or_index] 一个整数,指定元素检索位置(从0开始)td>
item(name_or_index) 返回集合中的指定索引的元素
namedItem(name) 返回集合中指定名称的元素


브라우저 지원

Internet ExplorerFirefoxOperaGoogle ChromeSafari

모든 주요 브라우저 행 컬렉션을 지원


테이블의 행의 수가 표시

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    alert(document.getElementById("myTable").rows.length);
}
</script>
</head>
<body>

<table id="myTable" border="1">
    <tr>
        <td>cell 1</td>
        <td>cell 2</td>
    </tr>
    <tr>
        <td>cell 3</td>
        <td>cell 4</td>
    </tr>
</table>
<br>
<button type="button" onclick="displayResult()">显示表的行数</button>

</body>
</html>

»시도


예

더 많은 예제

첫 번째 행의 팝 내용

행 추가

테이블 행의 셀 내용을 맞 춥니 다

수직 셀 콘텐츠 테이블의 행을 정렬

하나의 셀의 내용을 맞추고

셀 콘텐츠의 수직 배향

내용 변경 테이블 셀

병합 된 셀


테이블 객체 참조 표 개체