Open In App

HTML | DOM Abbreviation Object

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

The DOM Abbreviation Object is used to represent the HTML <abbr> element. The abbreviation element is accessed by getElementById().

Example 1: 

html




<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML DOM Abbreviation Object
        </title>
         
        <script>
            function myGeeks() {
                var abbr = document.getElementById("sudo").title;
                document.getElementById("geeks").innerHTML = abbr;
            }
        </script>
    </head>
     
    <body>
        <h2>DOM Abbreviation Object</h2>
         
        <abbr id = "sudo" title="GeeksforGeeks">
            GFG
        </abbr><br><br>
         
        <button onclick = "myGeeks()">
            Submit
        </button>
         
        <p id = "geeks"></p>
    </body>
</html>                   


Output: 

Before click on the button:

  

After click on the button:

  

Example 2: Abbreviation Object can be created by using the document.createElement Method. 

html




<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML DOM Abbreviation Object
        </title>
         
        <!-- script for creating Abbreviation Object -->
        <script>
            function myGeeks() {
                var w = document.createElement("ABBR");
                var f = document.createTextNode("GFG");
                w.setAttribute("title", "GeeksforGeeks");
                w.appendChild(f);
                document.getElementById("sudo").appendChild(w);
            }
        </script>
    </head>
     
    <body>
        <h2>DOM Abbreviation Object</h2>
         
        <button onclick = "myGeeks()">
            Submit
        </button>
 
        <p id = "sudo"></p>
         
    </body>
</html>                   


Output: 

Before Click on the button:

  

After click on the button:

  

Supported Browsers: The browser supported by DOM Abbreviation Object are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


Last Updated : 31 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads