I m using magnific popup in my project. To close this popup by jquery I am using $('.mfp-close').click(); and it's working but I have need to close by another way. Plz help me if any other way. Thanks in advance
Since the Magnific is a plugin of the jQuery framework, it needs to reference the jQuery library. This can be done by using the Google-hosted version of jQuery or downloading and using the distribution files. Include CSS: Add the magnific-popup.css file from the dist folder of Magnific.
These are some ways you can close this pop up: var magnificPopup = $.magnificPopup.instance; // save instance in magnificPopup variable magnificPopup.close (); // Close popup that is currently opened
enableEscapeKey: if it is true, the popup will close when click the escape key. To prevent this, assign the value false to close only when click on X (close) button in top right cornor of popup. By defualt, true is assigned for this.
The majority of lightbox plugins require you to define size of it via JS option. Magnific Popup does not - feel free to use relative units like EM's or resize lightbox with help of CSS media queries. Update content inside lightbox without worrying about how it'll resize and center.
Just use $.magnificPopup.close()
try this:
var magnificPopup = $.magnificPopup.instance;
// save instance in magnificPopup variable
magnificPopup.close();
// Close popup that is currently opened
Take a look here http://dimsemenov.com/plugins/magnific-popup/documentation.html#api
These are some ways you can close this pop up:
var magnificPopup = $.magnificPopup.instance; // save instance in magnificPopup variable
magnificPopup.close(); // Close popup that is currently opened
or
$.magnificPopup.close();
or
$('your-selector').magnificPopup('close');
For me, only the third one worked efficiently.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With