테이블 createTFoot() 메서드
예시
<tfoot> 요소를 만들고 여기에 <tr> 및 <td> 요소를 삽입합니다.
// 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>";
정의 및 사용
createTFoot() 메서드는 빈 <tfoot> 요소를 만들고 테이블에 추가합니다.
참고: <tfoot> 요소가 이미 테이블에 있는 경우 createTFoot() 메서드는 기존 요소를 반환하고 새 요소를 생성하지 않습니다.
참고: <tfoot> 요소에는 내부에 하나 이상의 <tr> 태그가 있어야 합니다.
팁: 테이블에서 <tfoot> 요소를 제거하려면 deleteTFoot() 메서드를 사용하십시오.
브라우저 지원
Method | |||||
---|---|---|---|---|---|
createTFoot() | Yes | Yes | Yes | Yes | Yes |
통사론
tableObject.createTFoot()
매개변수
없음 |
기술적 세부 사항
반환 값: | 새로 생성된(또는 기존) <tfoot> 요소 |
---|
더 많은 예
예시
<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();
}
관련 페이지
HTML 참조: HTML <tfoot> 태그
❮ 테이블 개체