Javascript DOM HTML Abbreviation Object get

Introduction

The Abbreviation object represents an HTML <abbr> element.

We can access an <abbr> element by using getElementById():

var x = document.getElementById("myAbbr");

Click the button to get the abbreviation of "CSS".

View in separate window

<!DOCTYPE html>
<html>
<body>

<p>The <abbr id="myAbbr" title="Cascading Style Sheets">CSS</abbr> stands for Cascading Style Sheets.</p>

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

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

<script>
function myFunction() {// w w  w.java  2s  .  c  om
  var x = document.getElementById("myAbbr").title;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related