DOM HTML td / e attribut headers
Définition et utilisation
ensembles de propriétés en-têtes ou retourne la tête en cours de la liste contenant l'unité de données en-tête de l'information d'en-tête.
La valeur de cet attribut est un nom inclus dans des guillemets, ces noms avec l'attribut id est défini dans un des noms différents de cellules d'en-tête de table.
grammaire
Réglage en-têtes propriétés:
tdObject.headers="header_ids"
or
thObject.headers="header_ids"
or
thObject.headers="header_ids"
Retourne les en-têtes des attributs:
tdObject.headers
or
thObject.headers
or
thObject.headers
Astuce: la propriété de têtesn'a pas de valeur par défaut.
值 | 描述 |
---|---|
header_ids | 定义以空格为分割符的表头单元id列表 |
support du navigateur
Tous les principaux navigateurs prennent en charge l'attribut headers
Exemples
Exemples
La deuxième ligne de l'en-tête:
<!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>
<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>
Essayez »
td / e objets