天天看點

td/th abbr 屬性

td/th 對象

定義和用法

abbr 屬性可設定或傳回表元中内容的縮寫版本(針對非可視的媒介,比如語音和盲文)。

如果設定了該屬性,使用者隻能聽到 abbr 屬性的值(不是單元中的内容)。

文法

設定 abbr 屬性:

tdObject.abbr="text"

或者

thObject.abbr="text"

傳回 abbr 屬性:

tdObject.abbr

thObject.abbr

提示:

abbr 屬性沒有預設值。

浏覽器支援

td/th abbr 屬性
td/th abbr 屬性
td/th abbr 屬性
td/th abbr 屬性
td/th abbr 屬性

所有主流浏覽器都支援 abbr 屬性。

執行個體

下面的例子可提示第一個單元格的 abbr::

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>菜鳥教程(runoob.com)</title>

<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">保持名稱簡短的縮寫,浏覽器可能重複顯示它們。</td>

        <td>單元格資料</td>

    </tr>

<tr>

<td>單元格資料</td>

</tr>

</table>

<br>

<button type="button" onclick="displayResult()">擷取第一個單元格的縮寫</button>

</body>

</html>

td/th 對象