HTML | DOM Abbreviation Object

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

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>                    

chevron_right


Output:
Before click on the button:

After click on the button:



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

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML DOM Abbreviation Object
        </title>
          
        <!-- script for 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>                    

chevron_right


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


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.