Disable click outside of bootstrap modal area to close modal

739 0 0 0

Last Updated : 2024-04-25 00:52:44

This snippet will teach you how to prevent modal close on clicking outside the bootstrap modal

There are 2 ways to prevent bootstrap modal from closing when clicking on the backdrop of modal (outside bootstrap modal) like this


$('#modal_id').modal({backdrop: 'static', keyboard: false})  

or using the data attribute like this


<button data-target="#myModal" data-toggle="modal" data-backdrop="static" data-keyboard="false">
Launch demo modal
</button>`

Mahmoud Anwar

Mahmoud Anwar

Back End Developer with a passion for developing innovative web applications that expedite the efficiency and effectiveness of organizational success. Well-versed in technology and writing code to create systems that are reliable and user-friendly. Also has the proven ability to motivate, educate, and collaborate effectively to build web applications and effectively track changes. Confident communicator, strategic thinker, and innovative creator to develop software that is customized to meet a company’s organizational needs, highlight their core competencies, and further their success.