टेबल क्रिएटहेड () मेथड
उदाहरण
एक <thead> तत्व बनाएं (और इसमें <tr> और <td> तत्व डालें):
// 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>";
परिभाषा और उपयोग
createTHead () विधि एक खाली <thead> तत्व बनाता है और इसे तालिका में जोड़ता है।
नोट: यदि कोई <thead> तत्व पहले से ही टेबल पर मौजूद है, तो createTHead () विधि मौजूदा को वापस कर देती है, और एक नया नहीं बनाती है।
नोट: <thead> तत्व के अंदर एक या अधिक <tr> टैग होने चाहिए।
युक्ति: किसी तालिका से <thead> तत्व को निकालने के लिए, deleteTHead() विधि का उपयोग करें।
ब्राउज़र समर्थन
Method | |||||
---|---|---|---|---|---|
createTHead() | Yes | Yes | Yes | Yes | Yes |
वाक्य - विन्यास
tableObject.createTHead()
मापदंडों
कोई नहीं |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | नव निर्मित (या मौजूदा) <थेड> तत्व |
---|
और ज्यादा उदाहरण
उदाहरण
एक <थेड> तत्व बनाएं और हटाएं:
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();
}
संबंधित पृष्ठ
HTML संदर्भ: HTML <थेड> टैग
टेबल ऑब्जेक्ट