Javascript DOM HTML DFN Object create

Introduction

We can create a <dfn> element via the document.createElement() method:

var x = document.createElement("DFN");

Click the button to create a DFN element with some text.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button><br><br>

<script>
function myFunction() {/*from w w w.j  a v a  2  s . c om*/
  var x = document.createElement("DFN");
  var t = document.createTextNode("A definition term");
  x.appendChild(t);
  document.body.appendChild(x);
}
</script>

</body>
</html>



PreviousNext

Related