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 >
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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
31 Jul, 2022
Like Article
Save Article