td/th abbr 屬性

定義和用法
abbr 屬性可設(shè)置或返回表元中內(nèi)容的縮寫版本(針對非可視的媒介,比如語音和盲文)。
如果設(shè)置了該屬性,用戶只能聽到 abbr 屬性的值(不是單元中的內(nèi)容)。
語法
設(shè)置 abbr 屬性:
tdObject.abbr="text"
或者
thObject.abbr="text"
或者
thObject.abbr="text"
返回 abbr 屬性:
tdObject.abbr
或者
thObject.abbr
或者
thObject.abbr
提示: abbr 屬性沒有默認(rèn)值。
瀏覽器支持
所有主流瀏覽器都支持 abbr 屬性。
實例
實例
下面的例子可提示第一個單元格的 abbr::
<html>
<head>
<script>
function displayResult()
{
var table=document.getElementById("myTable");
alert(table.rows[0].cells[0].abbr);
}
</script>
</head>
<body>
<table id="myTable" border="1">
? <tr>
??? <td abbr="def">Keep abbreviated names short.
??? Browsers may render them repeatedly.</td>
??? <td>cell data</td>
? </tr>
? <tr>
??? <td>cell data</td>
??? <td>cell data</td>
? </tr>
</table>
<br>
<button type="button" onclick="displayResult()">Get abbreviation</button>
</body>
</html>
<head>
<script>
function displayResult()
{
var table=document.getElementById("myTable");
alert(table.rows[0].cells[0].abbr);
}
</script>
</head>
<body>
<table id="myTable" border="1">
? <tr>
??? <td abbr="def">Keep abbreviated names short.
??? Browsers may render them repeatedly.</td>
??? <td>cell data</td>
? </tr>
? <tr>
??? <td>cell data</td>
??? <td>cell data</td>
? </tr>
</table>
<br>
<button type="button" onclick="displayResult()">Get abbreviation</button>
</body>
</html>
嘗試一下 ?

更多建議: