A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/ToggleEvent/ToggleEvent below:

ToggleEvent: ToggleEvent() constructor - Web APIs

ToggleEvent: ToggleEvent() constructor

Baseline 2023

Newly available

The ToggleEvent() constructor creates a new ToggleEvent object.

Syntax
new ToggleEvent(type, init)
Parameters
type

A string representing the type of event. In the case of ToggleEvent this is always beforetoggle or toggle.

init

An object containing the following properties:

newState

A string representing the state the element is transitioning to. Possible values are "open" and "closed".

oldState

A string representing the state the element is transitioning from. Possible values are "open" and "closed".

Examples

A developer would not use this constructor manually. A new ToggleEvent object is constructed when a handler is invoked as a result of a relevant event firing.

For example:

const popover = document.getElementById("mypopover");

// …

popover.addEventListener("beforetoggle", (event) => {
  if (event.newState === "open") {
    console.log("Popover is being shown");
  } else {
    console.log("Popover is being hidden");
  }
});
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3