ToggleEvent: oldState property
Baseline 2025Newly available
Since January 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The oldState
read-only property of the ToggleEvent
interface is a string representing the state the element is transitioning from.
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 |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
oldState |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.