Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | ontoggle Event Attribute

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The ontoggle event is triggered when the user open or close the <details> element. The <details> element is used to provide additional information/details that user can view or hide details according to requirement.
Supported Tags:

  • <details>

Syntax: 
 

<details ontoggle = "script">

Attribute Value: This attribute contains single value script which works when ontoggle event call.
Note: This Attribute works with details tag.
Example: 
 

html




<!DOCTYPE html >
<html>
    <head>
        <title>ontoggle event attribute</title>
        <style>
            body {
                text-align:center;
            }
            h1 {
                color:green;
            }
        </style>
    </head>
    <body>
        <h1>GeeksforGeeks</h1>
        <h2>ontoggle event attribute</h2>
         
 
<p>Click below to open the details.</p>
 
 
        <details ontoggle="Geeks()">
            <summary style="color:blue";>What is the full
            form of HTML</summary>
             
 
<p>Hyper Text Markup Language</p>
 
 
        </details>
        <script>
            function Geeks() {
            alert("The ontoggle event triggered");
            }
        </script>
    </body>
</html>                       

Output: 
 

Toggle Attribute

Supported Browser: The browser supported by ontoggle event attribute are listed below: 
 

  • Google Chrome 36.0
  • Edge 79.0
  • Opera 23.0
  • Firefox 49.0
  • Safari 10.1

 


My Personal Notes arrow_drop_up
Last Updated : 19 Aug, 2022
Like Article
Save Article
Similar Reads
Related Tutorials