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