![]() |
VOOZH | about |
Bootstrap 5 Popover getInstance() method is used to get the already existing instance of the bootstrap Popover and return that instance to the caller. This method does not create a new popover instance. The caller can use the instance to perform other tasks or to call other methods of the popover component.
bootstrap.Popover.getInstance("#element");This method accepts an HTML element or the selector of an element as its parameter.
This method returns the instance of the popover associated with the element that passes using the parameter.
Example 1: In this example, we used the getInstance() method of the popover to get the popover instance and then call its show() and hide() methods to make control its visibility.
Output:
Example 2: In this example, we used the getInstance() method of the popover to get the popover instance and then call its toggle() method to toggle its visibility using the button.
Output:
Reference: https://getbootstrap.com/docs/5.0/components/popovers/#getinstance