Execute a JavaScript when a <details> element is opened or closed:
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.
The numbers in the table specify the first browser version that fully supports the event.
Event | |||||
---|---|---|---|---|---|
ontoggle | 12.0 | Not supported | Not supported | 6.0 | 15.0 |
In HTML:
In JavaScript:
In JavaScript, using the addEventListener() method:
Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <details> |
DOM Version: | Level 3 Events |