HTML | DOM DD Object
The DOM DD Object is used to represent the HTML <DD> element. The DD element is accessed by getElementById().
Syntax:
document.getElementById("ID");
Where “id” is the ID assigned to the “dd” tag.
Example-1:
<!DOCTYPE html> < html > < head > < title >HTML dd Tag</ title > < style > h1 { color: green; } h1, h2 { text-align: center; } body { width: 70%; } dt { color: red; } </ style > </ head > < body > < h1 >GeeksForGeeks</ h1 > < h2 >DOM < dd > Object</ h2 > < dl > < dt >Geeks Classes</ dt > <!-- Assigning id to dd --> < dd id = "GFG" > It is an extensive classroom programme for enhancing DS and Algo concepts. </ dd > < br > < dt >Fork Python</ dt > < dd > It is a course designed for beginners in python. </ dd > < br > < dt >Interview Preparation</ dt > < dd > It is a course designed for preparation of interviews in top product based companies. </ dd > </ dl > < button onclick = "myGeeks()" > Submit </ button > < p id = "sudo" > </ p > < script > function myGeeks() { <!-- Accessing of dd object. --> var g = document.getElementById("GFG").innerHTML; document.getElementById("sudo").innerHTML = g; } </ script > </ body > </ html > |
Output:
Before Clicking On Button :
After Clicking On Button:
Example-2: DD Object can be created by using the document.createElement Method.
<!DOCTYPE html> < html > < head > < title >HTML dd Tag</ title > < style > h1 { color: green; } h1, h2 { text-align: center; } body { width: 70%; } dt { color: red; } </ style > </ head > < body > < center > < h1 >GeeksForGeeks</ h1 > < h2 >DOM < dd > Object</ h2 > < button onclick = "myGeeks()" >Submit</ button > < dl id = "GFG" > < dt >Geeks Classes</ dt > </ dl > < script > function myGeeks() { var g = document.createElement("DD"); var f = document.createTextNode( "It is an extensive classroom for" + " enhancing DS and Algo concepts."); g.appendChild(f); var w = document.getElementById("GFG"); w.appendChild(g); } </ script > </ center > </ body > </ html > |
Output :
Before Clicking on Button:
After Clicking on Button:
Supported Browsers: The browser supported by DOM DD Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Please Login to comment...