TableHeader abbr Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:TableHeader

Description

The abbr property sets or gets the abbr attribute, which sets a shorter version of the content in a header cell.

Set the abbr property with the following Values

Value Description
text? Sets a short description of the header cell content

Return Value

A String, representing a short description of the header cell content

The following code shows how to return the value of the abbr attribute of a <th> element with id "myTh":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
}
</style>//from w  w  w .j  av  a  2s .com
</head>
<body>



<table>
  <tr>
    <th id="myTh" abbr="Make">Item</th>
    <th abbr="Model">Value</th>
  </tr>
  <tr>
    <td>Toys</td>
    <td>1</td>
  </tr>
</table>
<br>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myTh").abbr = "Company";
    document.getElementById("demo").innerHTML = "changed";
}
</script>

</body>
</html>

Related Tutorials