问题描述:

Bootstrap popup is not showing up on click. Only "modal-open class" and "modal-backdropin" open in browser. But popup window is not showing.

Here is my code

<script>

$(function () {

$('#signup').on('click', function () {

$(this).attr('data-target') ;

$('#myModal').load('register.html');{

$(this).modal({ show: true });

};

});

});

</script>

<a href="register.html" id="signup" data-toggle="modal" data-target="#myModal">Sign Up</a>

网友答案:

Store the target in a variable and use it in the load function, and also note that an extra semicolon removed from load('register.html')';' from your original code

   $(function () {
            $('#signup').on('click', function () {
                var target = $(this).attr('data-target') ;
             $("#myModal").load(target, function() { 
               $("#myModal").modal("show"); 
             });
            });
      });
网友答案:

Personally, I would change the link to this...

<a data-content="register.html" id="signup" data-toggle="modal" data-target="#myModal">Sign Up</a>

Followed by jQuery like this...

(function()
{   
    $('#signup').on('click', function()
    {
        var target = $(this).data('content');            
        $("#myModal > .modal-dialog > .modal-content > .modal-body").load(target, function()
        {
            $(this).modal("show"); 
        });
    });
})();
相关阅读:
Top