Javascript DOM HTML Details Object create

Introduction

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

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

Click the button to create a DETAILS element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>
<script>
function myFunction() {//from w ww .ja v  a 2s  .c  o m
  var x = document.createElement("DETAILS");
  var t = document.createTextNode("Some additional details...");
  x.appendChild(t);
  document.body.appendChild(x);
}
</script>

</body>
</html>



PreviousNext

Related