Open In App

HTML | DOM Details open Property

The Details open property in HTML DOM is used to set or return whether the hidden information is visible or not to the user. This property is used to reflect the HTML open attribute. 

Syntax: 



detailsObject.open
detailsObject.open = true|false

Property Values: It accepts two property values which are listed below: 

Return Value: It returns a boolean value which represents that the hidden information would be visible or not.



Example 1: This example returns the Details open Property. 




<!DOCTYPE html>
<html>
<head>
    <title>
        DOM details open Property
    </title>
    <style>
        h2 {
            color: green;
            font-size: 35px;
        }
        summary {
            font-size: 40px;
            color: #090;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <center>
        <h2>DOM Details open Property </h2>
        <!-- assigning id to details tag. -->
        <details id="GFG">
            <summary>GeeksforGeeks</summary>
            <p>A computer science portal for geeks</p>
            <div>
                It is a computer science portal
                where you can learn programming.
            </div>
        </details>
        <br>
        <button onclick="myGeeks()">Submit</button>
        <script>
            function myGeeks() {
                 
                // Return the details open Property
                var x = document.getElementById("GFG");
                 
                // Display hidden information
                // using open property.
                x.open = true;
            }
        </script>
    </center>
</body>
</html>

Output: 
Before Clicking on Button: 

After Clicking on Button: 

Example 2: This example sets the Details open Property. 




<!DOCTYPE html>
<html>
<head>
    <title>DOM details open Property</title>
    <style>
        h2 {
            color: green;
            font-size: 35px;
        }
         
        summary {
            font-size: 40px;
            color: #090;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <center>
        <h2>DOM Details open Property </h2>
        <!-- assigning id to details tag. -->
        <details id="GFG">
            <summary>GeeksforGeeks</summary>
            <p>A computer science portal for geeks</p>
            <div>It is a computer science portal
                where you can learn programming.</div>
        </details>
        <br>
        <button onclick="myGeeks()">Submit</button>
        <p id="sudo" style="font-size:25px;"></p>
        <script>
            function myGeeks() {
                // set details open property
                var x = document.getElementById("GFG");
                 
                // Hide information
                // using open property.
            var g = x.open = false;
                document.getElementById("sudo").innerHTML = g;
            }
        </script>
    </center>
</body>
</html>

Output : 
Before Clicking on Button: 

After Clicking on Button: 

Supported Browsers: The browser supported by DOM Details open property are listed below: 


Article Tags :