Phương thức table createTFoot ()
Thí dụ
Tạo một phần tử <tfoot> (và chèn một phần tử <tr> và <td> vào nó):
// Find a <table> element with id="myTable":
var table = document.getElementById("myTable");
// Create an empty <tfoot> element and add it to the table:
var footer = table.createTFoot();
// Create an empty <tr> element and add it to the first position of <tfoot>:
var row = footer.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 footer</b>";
Định nghĩa và Cách sử dụng
Phương thức createTFoot () tạo một phần tử <tfoot> trống và thêm nó vào bảng.
Lưu ý: Nếu phần tử <tfoot> đã tồn tại trên bảng, phương thức createTFoot () trả về phần tử hiện có và không tạo phần tử mới.
Lưu ý: Phần tử <tfoot> phải có một hoặc nhiều thẻ <tr> bên trong.
Mẹo: Để xóa phần tử <tfoot> khỏi bảng, hãy sử dụng phương thức deleteTFoot () .
Hỗ trợ trình duyệt
Method | |||||
---|---|---|---|---|---|
createTFoot() | Yes | Yes | Yes | Yes | Yes |
Cú pháp
tableObject.createTFoot()
Thông số
Không có |
Chi tiết kỹ thuật
Giá trị trả lại: | Phần tử <tfoot> mới được tạo (hoặc hiện có) |
---|
Các ví dụ khác
Thí dụ
Tạo và xóa phần tử <tfoot>:
function myCreateFunction() {
var table = document.getElementById("myTable");
var footer = table.createTFoot();
var row = footer.insertRow(0);
var cell = row.insertCell(0);
cell.innerHTML = "<b>This is a table footer</b>";
}
function myDeleteFunction() {
document.getElementById("myTable").deleteTFoot();
}
Các trang liên quan
Tham chiếu HTML: thẻ HTML <tfoot>
❮ Đối tượng bảng