ontoggle Event
Example
Execute a JavaScript when a <details> element is opened or closed:
<details ontoggle="myFunction()">
Try it Yourself »
Definition and Usage
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 | Not supported | 48.0 | 6.0 | 15.0 |
Syntax
In JavaScript, using the addEventListener() method:
object.addEventListener("toggle", myScript);
Try it Yourself »
Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
Technical Details
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <details> |
DOM Version: | Level 3 Events |