ToggleEvent: oldState property
Baseline 2023Newly available
Since November 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
TheoldState read-only property of theToggleEvent interface is a string representing the state the element is transitioning from.
In this article
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> # dom-toggleevent-oldstate> |