ontoggleEvent

事件对象参考手册Event Object

Example

Execute JavaScript when the <details> element is opened or closed:

<details ontoggle="myFunction()">

Try it yourself »


Definition and Usage

The ontoggle event is triggered when the user opens or closes the <details> element.

The <details> element describes additional information that the user can view or hide as needed.


Browser Support

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


Syntax

In HTML:

<element ontoggle="myScript">Try it yourself

In JavaScript:

object.ontoggle=function(){myScript};Try it yourself

In JavaScript, using the addEventListener() method:

object.addEventListener("toggle", myScript);Try it yourself

Note:Internet Explorer 8 and earlier IE versions do not supportaddEventListener()the method.


Technical Details
Bubbles: No
Cancelable: No
Event type: Event
Supported HTML tags: <details>


事件对象参考手册Event Object Other Extensions