Javascript DOM HTML DList Object get

Introduction

The DList object represents an HTML <dl> element.

We can access a <dl> element by using document.getElementById():

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

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

View in separate window

<!DOCTYPE html>
<html>
<body>
<dl id="myDL">
  <dt>CSS</dt>
  <dd>to style</dd>
  <dt>HTML</dt>
  <dd>to mark</dd>
</dl>//from  w ww .  j  a  va  2  s.c  o  m
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myDL").innerHTML;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related