![]() |
VOOZH | about |
Bootstrap TooltipsgetInstance() Method is used to obtain the instance of tooltips while the tooltips are being used. This method can only work after the instance is pre-initialized. The tooltip instance linked to a DOM element may be obtained using this static function.
Syntax:
var tooltip-element =
document.getElementById("tooltip-id");
var tooltip-instance = bootstrap
.Tooltip.getInstance(tooltip-element);
Parameters: This method accepts argument either an HTML element or its selector.
Return Value: This method returns the current Bootstrap 5 Tooltips instance to the caller.
Example 1: The code example below demonstrates how to implement the getInstance() method using JavaScript on Tooltips on top and right.
Output:
Example 2: The code example below demonstrates how to implement the getInstance() method using JQuery on Tooltips with anchor tags on the bottom and left.
Output:
Reference: https://getbootstrap.com/docs/5.0/components/tooltips/#getinstance