Details open Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Details

Description

The open property sets or gets whether additional details/information should be visible to the user.

This property reflects the HTML open attribute.

Set the open property with the following Values

Value Description
true|false Sets whether additional details should be visible to the user
  • true - Details will be visible
  • false - Details will not be visible

Return Value

A Boolean, returns true if the details are visible, otherwise it returns false

The following code shows how to Show additional details:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<details id="myDetails">
  <summary>Copyright 2000-2018.</summary>
  <p> - by java2s.com. All Rights Reserved.</p>
  <p>All content and graphics on this web site are the property of the company java2s.com.</p>
</details>/* w  w w . j  ava2 s  .  co m*/

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
    document.getElementById("myDetails").open = true;
}
</script>

</body>
</html>

Related Tutorials