close modal bootstrap code example Example 1: data-dismiss= modal in jquery $(document).ready(function(){ // Open modal on page load $("#myModal").modal('show'); // Close modal on button click $(".btn").click(function(){ $("#myModal").modal('hide'); }); }); Example 2: close bootstrap modal with javascript $('#myModal').modal('hide'); Example 3: bootstrap modal Launch demo modal Modal title × ... Example 4: bootstrap 4 modal Launch demo modal Modal title × ... Example 5: bs modal service close this._bsModalRef.hide(); Example 6: bootstrap modal prevent close $('#myModal').modal({backdrop: 'static', keyboard: false})