Tablo createTHead() Yöntemi
Örnek
Bir <thead> öğesi oluşturun (ve buna bir <tr> ve <td> öğesi ekleyin):
// Find a <table> element with id="myTable":
var table = document.getElementById("myTable");
// Create an empty <thead> element and add it to the table:
var header = table.createTHead();
// Create an empty <tr> element and add it to the first position of <thead>:
var row = header.insertRow(0);
// Insert a new cell (<td>) at the first position of the "new" <tr> element:
var cell = row.insertCell(0);
// Add some bold text in the new cell:
cell.innerHTML = "<b>This is a table header</b>";
Tanım ve Kullanım
createTHead() yöntemi, boş bir <thead> öğesi oluşturur ve onu tabloya ekler.
Not: Tabloda zaten bir <thead> öğesi varsa, createTHead() yöntemi mevcut olanı döndürür ve yeni bir öğe oluşturmaz.
Not: <thead> öğesinin içinde bir veya daha fazla <tr> etiketi olmalıdır.
İpucu: Bir tablodan <thead> öğesini kaldırmak için deleteTHead() yöntemini kullanın.
Tarayıcı Desteği
Method | |||||
---|---|---|---|---|---|
createTHead() | Yes | Yes | Yes | Yes | Yes |
Sözdizimi
tableObject.createTHead()
parametreler
Hiçbiri |
Teknik detaylar
Geri dönüş değeri: | Yeni oluşturulan (veya mevcut) <thead> öğesi |
---|
Daha fazla örnek
Örnek
Bir <thead> öğesi oluşturun ve silin:
function myCreateFunction() {
var table = document.getElementById("myTable");
var header = table.createTHead();
var row = header.insertRow(0);
var cell = row.insertCell(0);
cell.innerHTML = "<b>This is a table header</b>";
}
function myDeleteFunction() {
document.getElementById("myTable").deleteTHead();
}
İlgili Sayfalar
HTML referansı: HTML <thead> etiketi
❮ Tablo Nesnesi