Javascript DOM HTML DD Object get

Introduction

The DD object represents an HTML <dd> element.

We can access a <dd> element via document.getElementById():

var x = document.getElementById("myDD");

Click the button to get the HTML content of the dd element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<dl>
  <dt>CSS</dt>
  <dd id="myDD">Cascading Style Sheets</dd>
</dl>//from  w w  w.  j  a va  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>



PreviousNext

Related