HTML ontoggle Event Attribute

Description

The event attribute ontoggle is triggered when the user opens or closes the <details> element. The <details> element defines additional information that can be displayed or hidden at the request of the user.

Syntax

<details ontoggle="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

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

Supported Tags

<details>

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
??????
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
??????