Firefox Tomorrow

web api instance property

ToggleEvent: oldState property

View on MDN ↗

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

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

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also