The tHead
property returns a reference to the <thead> element of a table.
tHead |
Yes | Yes | Yes | Yes | Yes |
var v = tableObject.tHead
A reference to the <thead> element of the table, or null if it is not defined.
The following code shows how to output the innerHTML of <thead>.
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {<!-- w w w . jav a2 s .co m-->
border: 1px solid black;
}
</style>
</head>
<body>
<table id="myTable">
<thead>
<tr>
<th>Item</th>
<th>Price</th>
</tr>
</thead>
<tfoot>
<tr>
<td>A</td>
<td>$1</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>B</td>
<td>$1</td>
</tr>
</tbody>
</table><br>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
console.log(document.getElementById("myTable").tHead.innerHTML);
}
</script>
</body>
</html>
The code above is rendered as follows: