Javascript Reference - HTML DOM DD Object








The DD object represents an HTML <dd> element.

Standard Properties and Events

The DD object also supports the standard properties and events.

Example

The following code shows how to get a <dd> element by using getElementById()


<!DOCTYPE html>
<html>
<body>
<dl>
  <dt>HTML</dt>
  <dd id="myDD">mark up</dd>
</dl><!--from   w  ww .  java  2 s  . c o m-->
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
    var x = document.getElementById("myDD").innerHTML;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to create a <dd> element by using the document.createElement() method.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button><br><br>
<dl id="myDL">
  <dt>HTML</dt>
</dl><!--  w w w  . j  a  v a2 s  .c  o m-->
<script>
function myFunction() {
    var x = document.createElement("DD");
    var t = document.createTextNode("mark up");
    x.appendChild(t);
    var y = document.getElementById("myDL");
    y.appendChild(x);
}
</script>

</body>
</html>

The code above is rendered as follows: