![]() |
VOOZH | about |
Bootstrap 5 List Group getInstance() method is used to get the instance of the tab attached with the DOM element passes as the parameter. This method returns the instance that can later be used to perform different operations like triggering other methods on the Tab pane.
Syntax:
const element = document.querySelector("#listItem-ID");
element.getInstance(element);
Parameters: The list group getInstance() method accepts a DOM element or its selector as the only parameter.
Return Value: This method returns the tab instance of the DOM element passes as the parameter to the caller.
Example 1: In this example, we used the getInstance() method of the list group to get the instance of a tab pane and then trigger its show() method.
Output:
Example 2: In this example, we used the getInstance() method to get the instance of the practice tab and triggered the dispose() method to destroy the instance, so that the tab cannot be controlled programmatically.
Output:
Reference:https://getbootstrap.com/docs/5.0/components/list-group/#getinstance