jquery - How do I close the modal from the backdrop? -
so have modal, , once open i'm able close via close button or x. however, able close clicking on backdrop. here code have far close modal.
function close_modal() { jquery('#details-modal').modal('hide'); settimeout(function() { jquery('#details-modal').remove(); jquery('.modal-backdrop').remove(); },500); }
i think give idea of how work
function myfunction() { var modal = document.getelementbyid('mymodal'); var span = document.getelementsbyclassname("close")[0]; span.onclick = function() { modal.style.display = "none"; } // when user clicks anywhere outside of modal, close window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } } }
Comments
Post a Comment