Javascript DOM HTML Details Object get

Introduction

The Details object represents an HTML <details> element.

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

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

Click the "Test" button to show additional details.

View in separate window

<!DOCTYPE html>
<html>
<body>
<details id="myDetails">
Some additional details...//w w  w .  j  a  va 2 s . c o  m
</details>
<button onclick="myFunction()">Test</button>
<script>
function myFunction() {
  var x = document.getElementById("myDetails");
  x.open = true;
}
</script>

</body>
</html>



PreviousNext

Related