HTML | ontoggle Event Attribute
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.
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:
<!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:

Supported Browser: The browser supported by ontoggle event attribute are listed below:
- Google Chrome 12.0
- Opera 15.0
- Firefox 48.0
- Safari 6.0
Recommended Posts:
- HTML | DOM ontoggle Event
- HTML | onpaste Event Attribute
- HTML | onoffline Event Attribute
- HTML | onkeyup Event Attribute
- HTML | oncontextmenu Event Attribute
- HTML | ondrop Event Attribute
- HTML | ondragleave Event Attribute
- HTML | onsubmit Event Attribute
- HTML | onwheel Event Attribute
- HTML | ondragenter Event Attribute
- HTML | onreset Event Attribute
- HTML | onunload Event Attribute
- HTML | onselect Event Attribute
- HTML | onresize Event Attribute
- HTML | ondrag Event Attribute
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.



