VOOZH about

URL: https://www.geeksforgeeks.org/bootstrap/bootstrap-5-modal-dispose-method/

⇱ Bootstrap 5 Modal dispose() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Bootstrap 5 Modal dispose() Method

Last Updated : 27 Jul, 2025

Bootstrap 5 modal provides us with some utility methods and they can be used to manage the modal in different ways. The dispose() method is used to destroy the modal instance which is automatically created when the modal is triggered. The instance of the modal is destroyed from the DOM by this method but the markup of the modal is not removed from the DOM. 

Syntax:

modalSelector.dispose();

Example 1: The code demonstrates how we can use the dispose() method using JavaScript, and we can use the dev tools in a browser like Chrome to understand how the modal's instance is being destroyed.

Output:

Example 2: The code demonstrates how we can use the dispose() method using jQuery, and we can use the dev tools in a browser like chrome to understand how the modal's instance is being destroyed.

Output:

Reference: https://getbootstrap.com/docs/5.0/components/modal/#dispose

Comment
Article Tags:

Explore