Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML | ontoggle Event Attribute

  • Difficulty Level : Basic
  • Last Updated : 03 Aug, 2021

The ontoggle event is triggered when the user open or close the <details> element. The <details> element is used to provide additional information/details that user can view or hide details according to requirement.
Supported Tags:

  • <details>


<details ontoggle = "script">

Attribute Value: This attribute contains single value script which works when ontoggle event call.
Note: This Attribute works with details tag.


<!DOCTYPE html >
        <title>ontoggle event attribute</title>
            body {
            h1 {
        <h2>ontoggle event attribute</h2>
<p>Click below to open the details.</p>
        <details ontoggle="Geeks()">
            <summary style="color:blue";>What is the full
            form of HTML</summary>
<p>Hyper Text Markup Language</p>
            function Geeks() {
            alert("The ontoggle event triggered");


Toggle Attribute

Supported Browser: The browser supported by ontoggle event attribute are listed below: 

  • Google Chrome 12.0
  • Opera 15.0
  • Firefox 48.0
  • Safari 6.0


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!