运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/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> </html>