Online Forum To Support Coders With Technical Assistance - Read Write Execute

Bootstrap Modal – How to stop modal from closing when clicking outside

Ankit Agrawal
Ankit Agrawal
Published on July 24, 2019 · 1 min read

bootstrap modal are built with html,css and js. they are positioned over everything. They are used to add dialogs to our website.

To prevent bootstrap modal from closing when clicking outside it we can use following code

1 : Using Html

<a data-controls-modal="your_modal_div_id" data-backdrop="static" data-keyboard="false" href="#">Click</a>

2: Using Javascript

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

Read more about bootstrap modal

Was this article helpful?
Ankit Agrawal

Ankit Agrawal

Author & Senior Engineer at CodeExecute

Writing practical engineering guides, debugging real-world bottlenecks, and creating free tools for developer productivity.

← Previous Article Return view as string in laravel Next Article → Bootstrap spinners – How to use spinners in website using bootstrap 4