Bootstrap modal hide is not working

后端 未结 20 1321
温柔的废话
温柔的废话 2020-12-09 08:11

Bootstrap modal hide is not working. Alert comes in else. but my modal is not hidden Added bootply. My issue is the same one.

相关标签:
20条回答
  • 2020-12-09 09:06

    One possible reson should be the order of jquery and bootstrap and your script is not in proper sequence. Below should be the sequence.

    1. <script src='js/jquery-3.2.1.min.js'></script>
    2. <script src='js/bootstrap.min.js'></script>
    3. your own script:
    <script type="text/javascript">
    $("#buy").click(function () {
       var a = 4;
       if (a == 5) {
         alert("if");
         $('#myModal').modal('show');
       }
       else {
        alert("else");
        $('#myModal').modal('hide');
       }
    
    });
    </script>
    
    0 讨论(0)
  • 2020-12-09 09:06

    Check if you closed all nested div inside main modal div

    <div data-backdrop="static" class="modal fade" id="modal-progress" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    
    -----NESTED DIV ------------------
    
    </div>
    
    0 讨论(0)
提交回复
热议问题