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:

  • It returns the Details open property.
    detailsObject.open
  • It is used to set the Details open property.
    detailsObject.open = true|false

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



  • true: It specifies the hidden information should be visible.
  • false: It specifies that the hidden information should not be visible.

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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() { 
                  
                // Accessing details tag. 
                var x = document.getElementById("GFG"); 
                  
                // Display hidden information 
                // using open property. 
                x.open = true; 
            
        </script
    </center
</body
  
</html>                    

chevron_right


Output:
Before Clicking on Button:

After Clicking on Button:

Example 2: This example sets the Details open Property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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() { 
                // Accessing details tag. 
                var x = document.getElementById("GFG"); 
                  
                // Display hidden information 
                // using open property. 
            var g = x.open = false;
                document.getElementById("sudo").innerHTML = g;
            
        </script
    </center
</body
  
</html>             

chevron_right


Output :
Before Clicking on Button:

After Clicking on Button:

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

  • Google Chrome
  • Internet Explorer 10.0 +
  • Firefox
  • Opera
  • Safar


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : shubham_singh, nidhi_biet



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.