HTML DOM TableHeader abbr 속성은 HTML 문서에 있는 테이블의 abbr 속성 값을 반환하고 수정합니다.
구문
다음은 구문입니다 -
1. 반환 약어
object.abbr
2. 약어 추가
object.abbr = “text”
abbr 속성의 예를 살펴보겠습니다.
예시
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
background: lightblue;
height: 100vh;
text-align: center;
}
table {
margin: 2rem auto;
width: 400px;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
margin: 1rem auto;
}
</style>
<body>
<h1>DOM TableHeader abbr Property Demo</h1>
<table border="2">
<thead>
<tr>
<th>Name</th>
<th>Language</th>
</tr>
<thead>
<tbody>
<tr>
<td id="john">John</td>
<td abbr="Eng" id="john-lang">English</td>
</tr>
<tr>
<td id="elon">Elon</td>
<td abbr="Ger" id="elon-lang">Germany</td>
</tr>
</tbody>
</table>
<button onclick="get()" class="btn">Show abbr Value</button>
<div class="show"></div>
<script>
function get() {
document.querySelector(".show").innerHTML = "abbr for English: " + document.querySelector("#john-lang").abbr;
}
</script>
</body>
</html> 출력

"약어 값 표시를 클릭합니다. ” 버튼을 눌러 abbr 속성 값을 표시합니다.
