Latest web development tutorials

HTML DOM td / th abbr attribute

td / th Object Reference td / th objects

Definition and Usage

abbr property sets or returns the bucket in an abbreviated version (for non-visual media such as speech and braille).

If this attribute is set, the user can hear the value (not the cell contents) abbr attribute.

grammar

Setting abbr attribute:

tdObject.abbr="text"

或者

thObject.abbr="text"

Back abbr attribute:

tdObject.abbr

或者

thObject.abbr

Tip: abbr attribute has no default value.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the abbr attribute.


Examples

Examples

The following example prompts the first cell abbr ::

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>
<td>单元格数据</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">获取第一个单元格的缩写</button>

</body>
</html>

try it"


td / th Object Reference td / th objects