![]() |
VOOZH | about |
In Bootstrap 5 Dropdowns, there are pre-defined methods that we can use to trigger different types of functionalities in dropdowns. The methods can be implemented using JavaScript and JQuery.
Bootstrap 5 Dropdowns Methods: The Dropdowns Methods with their function are given below:
Syntax:
dropdown-instance.toggle();Example 1: This example demonstrates the usage of the toggle(), getInstance(), and dispose() methods and you can see the instance and the disposing of it in the browser dev tools console(Press Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (Mac) to open the browser console panel.)
Output:
Example 2: The code below demonstrates how to use the hide(), show(), and the getOrCreateInstance() dropdowns methods and you can see the instance in the browser dev tools console(Press Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (Mac) to open the browser console panel.). Because the instance is not created at first and only created when the getOrCreateInstance is triggered, so here the first button needs to be clicked.
Output:
Reference:https://getbootstrap.com/docs/5.0/components/dropdowns/#methods