Create a DD Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:DD

Introduction

You can create a <dd> element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">create a DD element with some text.</button><br><br>

<dl id="myDL">
  <dt>CSS</dt>
</dl>/*from   w  ww  . ja v  a2s  .  co  m*/

<script>
function myFunction() {
    var x = document.createElement("DD");
    var t = document.createTextNode("for style");
    x.appendChild(t);

    var y = document.getElementById("myDL");
    y.appendChild(x);
}
</script>

</body>
</html>

Related Tutorials