Bootstrap Event when the modal is about to be hidden

The hide.bs.modal event in Bootstrap fires when the modal is about to be hidden.

Firstly, hide the Bootstrap modal on button click ?

$("#button1").click(function(){
  $("#newModal").modal("hide");
});

Now, use the hide.bs.modal class and generate the alert when the modal is about to hide on button click ?

$("#newModal").on('hide.bs.modal', function () {
  alert('The modal is about to be hidden.');
});

Let us see an example stating the usage of hide.bs.modal event ?

Example


  
    Bootstrap Example
    
    
    
    
    
    
  

  
   

Sample

   

This is demo text.

   

This is demo text.

   

This is demo text.

   

This is demo text.

   

This is demo text.

   

This is demo text.

   

This is demo text.

   

This is demo text.

   

This is demo text.

   

This is demo text.

   

This is demo text.

       
Updated on: 2026-03-11T22:50:42+05:30

143 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements