HTMLDetailsElement: toggle event

The toggle event fires when the open/closed state of a <details> element is toggled.

Bubbles No
Cancelable No
Interface Event
Event handler property None
Default Action Toggles the open state of the <details> element.


This example logs chapters that are open. Chapters are removed from the log when they are closed.


<aside id="log">
  <b>Open chapters:</b>
  <div data-id="ch1" hidden>I</div>
  <div data-id="ch2" hidden>II</div>
  <div data-id="ch3" hidden>III</div>
<section id="summaries">
  <b>Chapter summaries:</b>
  <details id="ch1">
    <summary>Chapter I</summary>
    Philosophy reproves Boethius for the foolishness of his complaints against Fortune. Her very nature is caprice.
  <details id="ch2">
    <summary>Chapter II</summary>
    Philosophy in Fortune's name replies to Boethius' reproaches, and proves that the gifts of Fortune are hers to give and to take away.
  <details id="ch3">
    <summary>Chapter III</summary>
    Boethius falls back upon his present sense of misery. Philosophy reminds him of the brilliancy of his former fortunes.


body {
  display: flex;
  flex-direction: row-reverse;

#log {
  flex-shrink: 0;
  padding-left: 3em;

#summaries {
  flex-grow: 1;


function logItem(e) {
  const item = document.querySelector(`[data-id=${}]`);

const chapters = document.querySelectorAll('details');
chapters.forEach((chapter) => {
  chapter.addEventListener('toggle', logItem);



Specification Status Comment
HTML Living Standard
The definition of 'toggle event' in that specification.
Living Standard

Browser compatibility

ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
toggle eventChrome Full support YesEdge Full support ≤79Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes


Full support
Full support
Compatibility unknown
Compatibility unknown