Javascript DOM HTML Details open Property get

Introduction

Find out if additional details are visible to the user:

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

Click button to find out if additional details are visible.</p>

View in separate window

<!DOCTYPE html>
<html>
<body>

<details id="myDetails" open>
  <summary>Copyright 2020-2024.</summary>
  <p> - by java2s.com. All Rights Reserved.</p>
  <p>All content on this web site are the property of the company.</p>
</details>/*from w  w w.  j  a v a  2 s.co  m*/
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

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

</body>
</html>



PreviousNext

Related