The oldState
read-only property of the ToggleEvent
interface is a string representing the state the element is transitioning from.
The oldState
read-only property of the ToggleEvent
interface is a string representing the state the element is transitioning from.
A string. Possible values are "open"
(the popover is going from showing to hidden) or "closed"
(the popover going from hidden to shown).
js
const popover = document.getElementById("mypopover"); // ... popover.addEventListener("beforetoggle", (event) => { if (event.oldState === "open") { console.log("Popover is being hidden"); } else { console.log("Popover is being shown"); } });
Specification |
---|
HTML Standard # dom-toggleevent-oldstate |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
oldState |
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/oldState