![]() |
VOOZH | about |
Bootstrap 5 Popovers toggle() method is used to toggle the visibility of the popover. The toggle() method can be used in place of the show() and hide() methods to change the visibility of the popover. The toggle() method returns to the caller before the popover is actually shown or hidden from the screen.
const element = new bootstrap.Popover.getOrCreateInstance("#popoverID");
element.toggle();
The popover toggle method does not accept any parameters.
This method does not return anything to the caller. It just toggles the popover of an element.
Example 1: In this example, we used the popover toggle method to toggle the visibility of the popover of an element.
Output:
Example 2: In this example, we used the toggle method of the popover with the show and the hide method.
Output:
Reference:https://getbootstrap.com/docs/5.0/components/popovers/#toggle