Pop-up not showing (with magnific-popup)

前端 未结 3 1970
南方客
南方客 2020-12-18 15:45

I\'m trying to implement magnific popup on my website but for some reason my test image is not opening in popup mode. What could be the issue? Many thanks

&l         


        
相关标签:
3条回答
  • 2020-12-18 15:59

    Problem in your code:

     $(document).ready(function() {
        $('.image-popup-vertical-fit').magnificPopup({
          type: 'image',
          closeOnContentClick: true,
          mainClass: 'mfp-img-mobile',
          image: {
            verticalFit: true
          }
     });
    

    Your problem, you have two opening script tags: });

    The proper version of script:

    $(document).ready(function() {
        $('.image-popup-vertical-fit').magnificPopup({
          type: 'image',
          closeOnContentClick: true,
          mainClass: 'mfp-img-mobile',
          image: {
            verticalFit: true
          }
      });
    });
    
    0 讨论(0)
  • 2020-12-18 16:14

    you should put

    (document).ready(function()
    

    inside the body, not the head

    0 讨论(0)
  • 2020-12-18 16:20

    Look at the JavaScript console. You got an error.

    Uncaught SyntaxError: Unexpected token < testpopup.html:14
    

    Click on the error message and it takes you to

    <script type="text/javascript">
    <script type="text/javascript">
    

    There is your problem, you have two opening script tags.

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