Javascript DOM HTML DFN Object get

Introduction

The DFN object represents an HTML <dfn> element.

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

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

Click the button to set the color of the definition term to red.

View in separate window

<!DOCTYPE html>
<html>
<body>
<dfn id="myDFN">Definition term</dfn>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*  w w  w .  j ava 2 s . co m*/
  var x = document.getElementById("myDFN");
  x.style.color = "red";
}
</script>

</body>
</html>



PreviousNext

Related