Home
Tutorials
Microsoft Technologies Tutorials
Java Programming Tutorials
Web Designing Tutorials
Script Programming Tutorials
Database Programming Tutorials
Mobile Technologies Tutorials
Other Programming Tutorials
Examples
Articles
Tools
News
Bootstrap Modal Events Example
Keywords : modal, bootstrap, bootstrap modal, bootstrap modals, bootstrap 4 modal, bootstrap modals examples, bootstrap modal via data attributes, bootstrap modal events with javascript, modal show/hide events
Example
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Modal Events Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> <style> .bcontent { margin-top: 10px; } </style> <script> $(function() { $("#sampleModal").on('show.bs.modal',function(event) { alert('The modal window will be shown now'); }); $("#sampleModal").on('hidden.bs.modal',function(event) { alert('The modal window is dismissed'); }); }); </script> </head> <body> <div class="container bcontent"> <h2>Bootstrap Modal Events</h2> <hr /> <button type="button" id="btnShow" class="btn btn-primary" data-toggle="modal" data-target="#sampleModal"> Launch modal </button> <div class="modal fade" id="sampleModal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Tutlane Note</h5> <button type="button" class="close" data-dismiss="modal"> <span>×</span> </button> </div> <div class="modal-body"> <p>Tutlane.com is an eLearning organization providing quality online tutorials, articles, and information related to the latest programming technologies.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button> </div> </div> </div> </div> </div> </body> </html>
Click Here to See Result
Result
Previous
Next