Modal doesn't show up using bootstrap

后端 未结 1 1240
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-20 11:13

Whenever I press the button , the modal just won\'t show up, I tried so many things even creating a custom.js to put this code in

$(\'#myModal\').modal(\'sh         


        
相关标签:
1条回答
  • 2021-01-20 11:57

    Problem is that jQuery 3.0.0-alpha1 version Not Fully Supported by bootstrap 3.3.5

    Reason modal not showing

    • either modal trigger by button using default bootstrap behavior OR
    • opening the modal with jQuery $("#myModal").modal("show")

    is because .modal property display:none is not changing to display:block

    Fiddle

    Solution-1

    Switch back to last stable version of jQuery jQuery 2.x

    Solution-2 using jQuery 3.0.0-alpha1

    Use bootstrap modal event listener and change .modal property from display:none to diaply:block when modal shown.;

    If using button to trigger the modal

    $(document).ready(function () {
        $("#myModal").on('shown.bs.modal', function () {
            $(".modal").css('display', 'block');
        })
    });
    

    Fiddle

    If using jQuery to open the modal

    $(document).ready(function () {
        $("#myModal").modal("show").on('shown.bs.modal', function () {
            $(".modal").css('display', 'block');
        })
    });
    

    Fiddle

    0 讨论(0)
提交回复
热议问题