![]() |
VOOZH | about |
Bootstrap 5 Popovers getOrCreateInstance() method is used to obtain the instance of tooltips while the tooltips are being used. This method can work even when the instance is not pre-initialized and this method creates an instance if there isn't one available.
Syntax:
var popover-element =
document.getElementById("popover-id");
var popover-instance =
bootstrap.Tooltip.getOrCreateInstance(popover-element);
Parameters: This method accepts as an argument either an HTML element or its selector.
Return Value: This method returns the current Popover instance to the caller. If no instance is yet created, it creates one.
Example 1: This example demonstrates the basic implementation of the Popovers getOrCreateInstance() method using JavaScript and the top and right popovers.
Output:
Example 2: This example demonstrates the basic implementation of the Popovers getOrCreateInstance() method using jQuery and the bottom and top popovers.
Output:
Reference:https://getbootstrap.com/docs/5.0/components/popovers/#getorcreateinstance