W3cubDocs

/Web APIs

ToggleEvent: newState property

Baseline 2023
Newly available

Since ⁨November 2023⁩, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The newState read-only property of the ToggleEvent interface is a string representing the state the element is transitioning to.

Value

A string. Possible values are "open" (the popover is being shown) or "closed" (the popover is being hidden).

Examples

const popover = document.getElementById("mypopover");

// …

popover.addEventListener("beforetoggle", (event) => {
  if (event.newState === "open") {
    console.log("Popover is being shown");
  } else {
    console.log("Popover is being hidden");
  }
});

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
newState 114 114 120 100 17 114 120 76 17 23.0 114 17

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ToggleEvent/newState