The oldState
read-only property of the ToggleEvent
interface is a string representing the state the element is transitioning from.
On this page
ToggleEvent: oldState property
Value
A string. Possible values are "open"
(the popover is going from showing to hidden) or "closed"
(the popover going from hidden to shown).
Examples
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");
}
});
Specifications
Specification |
---|
HTML Standard # dom-toggleevent-oldstate |
Browser compatibility
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 |
See also
© 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