Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The toggle
event of the HTMLElement
interface fires on a popover element (i.e. one that has a valid popover
attribute) just after it is shown or hidden.
- If the popover element is transitioning from hidden to showing, the
event.oldState
property will be set toclosed
and theevent.newState
property will be set toopen
. - If the popover element is transitioning from showing to hidden, then
event.oldState
will beopen
andevent.newState
will beclosed
.
Note: The toggle
event behaves differently when fired on <details>
elements. In this case, it does not relate to popovers, and instead fires when the open
/closed
state of a <details>
element is toggled. See the HTMLDetailsElement
toggle event
page for more information.