ontoggle Event
Example
Call a function when a <details> element is opened or closed:
<details ontoggle="myFunction()">
Try it Yourself »
Description
The ontoggle event occurs when the user opens or closes the <details> element.
The <details> element specifies additional details that the user can view or hide on demand.
Browser Support
The numbers in the table specify the first browser version that fully supports the event.
| Event | |||||
|---|---|---|---|---|---|
| ontoggle | 12.0 | 79.0 | 48.0 | 6.0 | 15.0 |
Syntax
In JavaScript, using the addEventListener() method:
object.addEventListener("toggle", myScript);
Try it Yourself »
Technical Details
| Bubbles: | No |
|---|---|
| Cancelable: | No |
| Event type: | Event |
| HTML tags: | <details> |
| DOM Version: | Level 3 Events |