VOOZH about

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

⇱ Bootstrap 5 Popovers Methods - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Bootstrap 5 Popovers Methods

Last Updated : 31 Jul, 2024

Bootstrap 5 Popovers methods enable manual control over the visibility of popover elements, allowing users to show or hide them as needed, enhancing interactivity and customization options within web applications.

Bootstrap 5 Popovers Methods:

MethodDescription
toggleToggles the visibility of a popover element.
showShows a popover element.
hideHides a popover element.
disposeDisposes of a popover element.
enableEnables a popover element to be visible.
disableDisables a popover element from being visible.
toggleEnabledToggles a popover element's ability to be visible.
updateUpdates the position of a popover element.
getInstanceStatic method to get the popover element associated with the DOM.
getOrCreateInstanceStatic method to get the popover element associated with the DOM, or create a new one if it doesn't exist.

Syntax:

myPopover.popover_method()

Let us understand more about this using some examples below:

Example 1: In this example, we will show and hide the popover element using the "show" and "hide" methods given by the Bootstrap 5 Popover object.

Output:


👁 Bootstrap-5-Popovers-methods2
Bootstrap 5 Popovers Methods Example Output

Example 2: In this example, we will toggle and dispose of the popover element using the "toggle" and "dispose" methods given by the Bootstrap 5 Popover object. Once we dispose of a popover element, we cannot use any methods given by the Bootstrap 5 Popover object as it gets destroyed in the DOM. 

Output:

👁 Bootstrap-5-Popovers-methods3
Bootstrap 5 Popovers Methods Example Output
Comment

Explore