Javascript DOM HTML DT Object get

Introduction

The DT object represents an HTML <dt> element.

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

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

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

View in separate window

<!DOCTYPE html>
<html>
<body>
<dl>
  <dt id="myDT">CSS</dt>
  <dd>to style web page</dd>
</dl>//from  w  w w  . j  a va2 s  .c  o  m
<button onclick="myFunction()">Test</button>

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

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

</body>
</html>



PreviousNext

Related