Prevent modal from hiding when being clicked outside

229 0 0 0

Last Updated : 2021-09-16 18:39:37

Sometimes, when a modal appears you donot want to be hidden if you clicked outside it in the gray area around it in the whole page. to prevent that behavoir, Use the following small code to prevent all modals from this action:

//Prevent hidding modal when clicked outside
$('div.modal').modal({
show : false,
backdrop: 'static',
keyboard: false
})

Mohammed Anwar

Mohammed Anwar

Experienced technical lead PHP, MySQL and Laravel Developer for 15+ years, with proven ability to develop and create high-quality and optimized web applications. Great ability to build and optimize database design, schema and queries. Versed programing trainer and instructor delivering web courses and helping others to get into the field in a timely manner. Fast and eager learner for new technologies .