javascript - Can't disable the feature to click outside of modal and close - TagMerge
2Can't disable the feature to click outside of modal and closeCan't disable the feature to click outside of modal and close

Can't disable the feature to click outside of modal and close

Asked 1 years ago
4
2 answers

Add the show property to the modal and only call once

<script type="text/javascript"> 
$(window).on('load',function(){
    $("#my_modal").modal({
        backdrop: 'static',
        keyboard: false,
        show: true // added property here
    });
});
</script>

Source: link

0

I just used .add instead of .toggle inside window event which fixed the issue.

function windowOnClick(event) {
  console.log(event.target)
    if (event.target == modal) {
         modal.classList.add("modal-show");
    }
}

Source: link

Recent Questions on javascript

    Programming Languages