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