DOM HTMLElement.showPopover() Method
The showPopover() method opens an element that has the popover attribute. hidePopover() and togglePopover() close or toggle it.
Description
The showPopover() method shows an element that has the popover attribute, placing it in the top layer above other content. hidePopover() hides it and togglePopover() switches it. Popovers with popover="auto" close when the user clicks outside or presses Escape.
Often no JavaScript is needed at all: a button with popovertarget opens and closes a popover declaratively. The toggle event reports when it opens or closes.
Calling showPopover() on a popover that's already open, or on an element without the popover attribute, throws an error, so check the :popover-open state with matches() first, or use togglePopover(). Popovers are often positioned next to their trigger with CSS anchor positioning.
Syntax
element.showPopover()
element.hidePopover()
element.togglePopover()Return Value
None for showPopover() and hidePopover(); togglePopover() returns true if the popover is now open.
Example
Browser Support
The following information will show you the current browser support for the HTMLElement.showPopover() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





