Call a function when a <details> element is opened or closed:
<details ontoggle="myFunction()">
Try it Yourself »
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 | 79.0 | 48.0 | 6.0 | 15.0 |
In JavaScript, using the addEventListener() method:
object.addEventListener("toggle",
myScript);
Try it Yourself »
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
HTML tags: | <details> |
DOM Version: | Level 3 Events |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!