![]() |
VOOZH | about |
The Bootstrap 5 Modal toggle() method is used to directly toggle a modal i.e. show or hide. This method shows the result before the show or hide event occurs.
modal.toggle()The user receives a direct response from this method before the modal is ever displayed or hidden.
Example 1: In this article, we used the toggle() method of the Bootstrap 5 Modal component to toggle its visibility. Here the modal's visibility is toggled when we click the button and after 3 seconds it toggles its visibility again.
Output:
Example 2: This is another example illustrating the use of the toggle() method of the Modal component with buttons.
Output:
Reference: https://getbootstrap.com/docs/5.0/components/modal/#toggle