THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

ontoggle Event

Event Object Reference Event Object

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 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: 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

Event Object Reference Event Object