Latest web development tutorials

HTML의 DOM의 TD / 일 헤더 속성

TD / 일 객체 참조 TD / 일 객체

정의 및 사용

헤더 특성 세트 또는 데이터 유닛의 헤더 정보의 헤더를 포함하는리스트의 현재 헤드를 반환한다.

이 속성의 값은 인용 부호에 포함 된 이름, id 속성 이러한 이름은 다른 테이블 헤더 셀 이름에 정의되어 있습니다.

문법

헤더 속성 설정 :

tdObject.headers="header_ids"

or

thObject.headers="header_ids"

헤더 특성을 반환합니다 :

tdObject.headers

or

thObject.headers

팁 : 헤더 속성에는 기본값이 없습니다.

描述
header_ids 定义以空格为分割符的表头单元id列表


브라우저 지원

Internet ExplorerFirefoxOperaGoogle ChromeSafari

모든 주요 브라우저 헤더 속성 지원


헤더의 두 번째 줄 :

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    var table=document.getElementById("myTable");
    for (var i=0;i<table.rows[1].cells.length;i++){
        alert(table.rows[1].cells[i].headers);
    }
}
</script>
</head>
<body>

<table id="myTable" border="1" width="100%">
    <tr>
        <th id="name">名称</th>
        <th id="email">Email</th>
        <th id="phone">电话</th>
        <th id="addr">地址</th>
    </tr>
    <tr>
        <td headers="name">John Doe</td>
        <td headers="email">[email protected]</td>
        <td headers="phone">+45342323</td>
        <td headers="addr">Rosevn 56,4300 Sandnes,Norway</td>
    </tr>
</table>
<br>
<button type="button" onclick="displayResult()">获取第二行的单元格表头</button>

</body>
</html>

»시도


TD / 일 객체 참조 TD / 일 객체