``` --- ## Definition and Usage"> ``` --- ## Definition and Usage" />
Easy Tutorial
❮ Ref Eventattributes Att Link Media ❯

HTML ontoggle Event Attribute

HTML Event Attributes

Example

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

<details ontoggle="myFunction()">

Definition and Usage

The ontoggle attribute triggers when the user opens or closes the <details> element.

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


Browser Support

The numbers in the table specify the first browser version that supports the event.

Event Attribute
ontoggle 12.0 Not supported Not supported 6.0 15.0

Differences Between HTML 4.01 and HTML5

The ontoggle attribute is new in HTML5.


Syntax

Attribute Values

Value Description
script Script to be run on ontoggle

| Supported HTML Tags: | <details> | | --- | --- |


Related Pages

HTML DOM Reference: ontoggle Event

HTML Event Attributes

❮ Ref Eventattributes Att Link Media ❯