Search code examples
javascriptjqueryhtmlpopupmagnific-popup

Onclick anywhere on page close popup - Magnific Popup


I am using Magnific Popup.

I want to close popup when click anywhere on page close popup.

Here is my code fiddle:

http://jsfiddle.net/qweWa/24/

Code :

$('.popup-modal').magnificPopup({

    type: 'inline',
    modal: true,

});

$(document).on('click', '.closePopup', function (e) 
            {
                e.preventDefault();
                $.magnificPopup.close();
});

Solution

  • Slight adjustment ,check fiddle :)

    $('.popup-modal').magnificPopup({

    type: 'inline',
    modal: false,
    

    });

    > $(document).on('click', '.closePopup', function (e) 
    >             {
    >                 e.preventDefault();
    >                 $.magnificPopup.close();
    >             });
    

    http://jsfiddle.net/qweWa/27/