HTMLElement: beforetoggle event
The beforetoggle
event fires when an element with the popover
attribute is about to be opened or closed.
If the element is currently not open, then the .oldState
property will be set to closed
and the .newState
property will be set to open
; otherwise if the element is open, then .oldState
will be open
and .newState
will be closed
.
Syntax
Use the event name in methods like addEventListener()
, or set an event handler property.
addEventListener("beforetoggle", (event) => {});
onbeforetoggle = (event) => {};
Event type
A ToggleEvent
. Inherits from Event
.
Event properties
This interface inherits properties from its parent Event
.
ToggleEvent.oldState
Read only-
Returns either
open
orclosed
, depending on which state the element is transitioning from. ToggleEvent.newState
Read only-
Returns either
open
orclosed
, depending on which state the element is transitioning to.
Specifications
Specification |
---|
HTML Standard # event-beforetoggle |
Browser compatibility
BCD tables only load in the browser