JavaScript Reference/Javascript Methods/createTHead

Материал из Web эксперт
Перейти к: навигация, поиск

"createTHead()" Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
   var m = document.all.myTable.createTFoot();
   m.bgColor = "red"; 
}
function function2() {
   var n = document.all.myTable.createTHead();
   n.bgColor = "yellow"; 
} 
</script>
<table id="myTable">
    <thead id="th">
        <tr>
            <th>Cell 1</th>
            <th>Cell 2</th>
        </tr>
    <tfoot id="tf">
        <tr><td>Cell 3</td>
            <td>Cell 4</td>
        </tr>
</table>
<input type="button" value="Create foot and set color to red" onclick="function1();">
<input type="button" value="Create head and set color to yellow" onclick="function2();">
</body>
</html>



"createTHead()" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<table>                                                       |
+----------------+--------------------------------------------------------------+



"createTHead()" Syntax, Parameters and Note

Note:
These methods create empty <thead> rows for the table.
    
Syntax:
    
document.getElementById("tableID").createTFoot()
document.all.tableID.createTFoot() // IE only 
document.getElementById("tableID").createTHead()
document.all.tableID.createTHead() // IE only