Edit This Code:
See Result »
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="../../maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="../../ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="../../maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <style> #myBtn { width: 300px; padding: 10px; font-size:20px; position: absolute; margin: 0 auto; right: 0; left: 0; bottom: 50px; z-index: 9999; } </style> </head> <body> <div class="container"> <h2>Modal Events - hide.bs.modal</h2> <!-- Trigger the modal with a button --> <button type="button" class="btn btn-info btn-md" id="myBtn">Hide Modal</button> <!-- Modal --> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Modal Header</h4> </div> <div class="modal-body"> <p>The <strong>hide.bs.modal</strong> event occurs modal is about to be hidden.</p> <p>Click the "Hide Modal" button to trigger the hide method (which will trigger the hide.bs.modal event).</p> </div> </div> </div> </div> </div> <script> $(document).ready(function(){ $("#myModal").modal("show"); $("#myBtn").click(function(){ $("#myModal").modal("hide"); }); $("#myModal").on('hide.bs.modal', function () { alert('The modal is about to be hidden.'); }); }); </script> </body> <!-- Mirrored from www.w3schools.com/bootstrap/tryit.asp?filename=trybs_ref_js_modal_event_hide&stacked=h by HTTrack Website Copier/3.x [XR&CO'2014], Sun, 13 Mar 2016 11:05:05 GMT --> </html>
Result: