HTML DOM टेबल tFoot प्रॉपर्टी HTML दस्तावेज़ में टेबल के <tfoot> एलिमेंट को लौटाती है।
सिंटैक्स
object.tFoot
उदाहरण: tFoot दिखाना
<!DOCTYPE html>
<html>
<style>
body { color: #000; background: lightblue; height: 100vh; text-align: center; }
table { margin: 2rem auto; }
.btn { background: #db133a; border: none; height: 2rem; border-radius: 2px; width: 40%; display: block; color: #fff; outline: none; cursor: pointer; margin: 1rem auto; }
.show { font-size: 1.2rem; }
</style>
<body>
<h1>DOM टेबल tFoot प्रॉपर्टी डेमो</h1>
<table border="2">
<thead>
<tr> <th>नाम</th> <th>रोल नं.</th> </tr>
</thead>
<tbody>
<tr> <td>जॉन</td> <td>071717</td> </tr>
<tr> <td>जेन</td> <td>031717</td> </tr>
</tbody>
<tfoot>
<tr> <td colspan="2">टेबल फुटर</td> </tr>
</tfoot>
</table>
<button onclick="get()" class="btn">tFoot दिखाएं</button>
<div class="show"></div>
<script>
function get() {
var tableFooter = document.querySelector('table').tFoot;
document.querySelector(".show").innerHTML = tableFooter.innerHTML;
}
</script>
</body>
</html>
आउटपुट
- प्रारंभ में: टेबल हेडर, बॉडी, फुटर के साथ दिखती है
- "tFoot दिखाएं" क्लिक: फुटर का HTML कंटेंट ("<tr><td colspan="2">टेबल फुटर</td></tr>") प्रदर्शित होता है
tFoot प्रॉपर्टी के उपयोग
- पढ़ना: मौजूदा फुटर कंटेंट प्राप्त करना
- संशोधित करना:
table.tFoot.innerHTML = "..."
- स्टाइलिंग:
table.tFoot.style.fontWeight = "bold"
- जांचना:
if (table.tFoot) { ... } - फुटर मौजूद है या नहीं
tFoot vs createTFoot()
| पहलू |
tFoot प्रॉपर्टी |
createTFoot() मेथड |
| यदि मौजूद नहीं |
null लौटाता है |
बनाता है और लौटाता है |
| यदि मौजूद है |
मौजूदा लौटाता है |
मौजूदा लौटाता है |
| उपयोग |
पढ़ने/जांचने के लिए |
सुनिश्चित करने के लिए कि मौजूद है |
टेबल सेक्शन प्रॉपर्टीज सारांश
| प्रॉपर्टी |
एलिमेंट |
विवरण |
tHead |
<thead> |
टेबल हेडर (कॉलम शीर्षक) |
tFoot |
<tfoot> |
टेबल फुटर (कुल/सारांश) |
caption |
<caption> |
टेबल शीर्षक/विवरण |
tBodies |
<tbody>[] |
सभी टेबल बॉडी सेक्शन्स |