HTML ontoggle event Attribute

❮ HTML Event Attributes


<details ontoggle="myFunction()">
  <p>The first version of HTML was written by Tim Berners-Lee in 1993. Since then, there have been many different versions of HTML. The most widely used version throughout the 2000`s was HTML 4.01, which became an official standard in December 1999.</p>


The ontoggle attribute specifies the script to be run when the user opens or closes the <details> element.

Standard Syntax

<element ontoggle="script">

Browser Support


Attribute Values

Value Description
script Specifies the script to be run on ontoggle

Technical Details

Supported HTML elements:

❮ HTML Event Attributes