admin管理员组

文章数量:1022240

I am using Magnific Popup.

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

Here is my code fiddle:

/

Code :

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

    type: 'inline',
    modal: true,

});

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

I am using Magnific Popup.

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

Here is my code fiddle:

http://jsfiddle/qweWa/24/

Code :

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

    type: 'inline',
    modal: true,

});

$(document).on('click', '.closePopup', function (e) 
            {
                e.preventDefault();
                $.magnificPopup.close();
});
Share Improve this question asked Feb 21, 2014 at 6:19 Hassan SardarHassan Sardar 4,52317 gold badges61 silver badges92 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 2

Slight adjustment ,check fiddle :)

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

type: 'inline',
modal: false,

});

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

http://jsfiddle/qweWa/27/

You need to set modal: false

Demo Fiddle

modal: When set to true, the popup will have a modal-like behavior: it won’t be possible to dismiss it by usual means (close button, escape key, or clicking in the overlay).

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

    type: 'inline',
    modal: false

});

From Magnific-Popup Documentation There's actually no need to set modal:false explicitly. Which most of the answers have done.

If you go through the documentation you'll find that, If you don't even pass the modal attribute it work. I've edited JSFiddle as per your requirement. I think unnecessary override a attribute can be avoided in this case.

Just these would be fine:

$('.popup-modal').magnificPopup({
    type: 'inline',
});

Note: Don't forget to note the difference of this answer with another answers.

I am using Magnific Popup.

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

Here is my code fiddle:

/

Code :

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

    type: 'inline',
    modal: true,

});

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

I am using Magnific Popup.

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

Here is my code fiddle:

http://jsfiddle/qweWa/24/

Code :

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

    type: 'inline',
    modal: true,

});

$(document).on('click', '.closePopup', function (e) 
            {
                e.preventDefault();
                $.magnificPopup.close();
});
Share Improve this question asked Feb 21, 2014 at 6:19 Hassan SardarHassan Sardar 4,52317 gold badges61 silver badges92 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 2

Slight adjustment ,check fiddle :)

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

type: 'inline',
modal: false,

});

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

http://jsfiddle/qweWa/27/

You need to set modal: false

Demo Fiddle

modal: When set to true, the popup will have a modal-like behavior: it won’t be possible to dismiss it by usual means (close button, escape key, or clicking in the overlay).

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

    type: 'inline',
    modal: false

});

From Magnific-Popup Documentation There's actually no need to set modal:false explicitly. Which most of the answers have done.

If you go through the documentation you'll find that, If you don't even pass the modal attribute it work. I've edited JSFiddle as per your requirement. I think unnecessary override a attribute can be avoided in this case.

Just these would be fine:

$('.popup-modal').magnificPopup({
    type: 'inline',
});

Note: Don't forget to note the difference of this answer with another answers.

本文标签: javascriptOnclick anywhere on page close popupMagnific PopupStack Overflow