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: In this example, we will use DOM DD Object.
HTML
<!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 >
< 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() {
let g =
document.getElementById("GFG").innerHTML;
document.getElementById("sudo").innerHTML
= g;
}
</ script >
</ body >
</ html >
|
Output:
Example 2: DD Object can be created by using the document.createElement Method.
HTML
<!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 >
< button onclick = "myGeeks()" >Submit</ button >
< dl id = "GFG" >
< dt >Geeks Classes</ dt >
</ dl >
< script >
function myGeeks() {
let g = document.createElement("DD");
let f = document.createTextNode(
"It is an extensive classroom for"
+ " enhancing DS and Algo concepts.");
g.appendChild(f);
let w = document.getElementById("GFG");
w.appendChild(g);
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers: The browser supported by DOM DD 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 :
13 Jun, 2023
Like Article
Save Article