VOOZH about

URL: https://www.geeksforgeeks.org/bootstrap/bootstrap-5-popovers-getinstance-method/

⇱ Bootstrap 5 Popovers getInstance() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Bootstrap 5 Popovers getInstance() Method

Last Updated : 29 Jul, 2024

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.

Syntax:

bootstrap.Popover.getInstance("#element");

Parameters:

This method accepts an HTML element or the selector of an element as its parameter.

Return Value:

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:

👁 Recording-2024-07-25-at-002443-(4)

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:

👁 img-10


Reference: https://getbootstrap.com/docs/5.0/components/popovers/#getinstance

Comment

Explore