The newState
read-only property of the ToggleEvent
interface is a string representing the state the element is transitioning to.
The newState
read-only property of the ToggleEvent
interface is a string representing the state the element is transitioning to.
A string. Possible values are "open"
(the popover is being shown) or "closed"
(the popover is being hidden).
js
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"); } });
Specification |
---|
HTML Standard # dom-toggleevent-newstate |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
newState |
114 | 114 | 114 | No | 100 | 17 | 114 | 114 | No | No | 17 | No |
© 2005–2023 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