admin管理员组文章数量:1333451
Hope you can help me. I read and read again the documentation of Magnific Popup, but I'm not good enough with javascript.
1- I open a popup with this link :
<a href="mysubpage.html" class="pop">OPEN POPUP</a>
and this javascript :
$('.pop').magnificPopup({ type:'iframe', showCloseBtn : true, closeOnBgClick : true, midClick: true });
2- in my popup, I would like a button 'CLOSE' to close the pop-up.
I try this but it doesn't worked :
<input type="button" value="CLOSE" onclick="magnificPopup.close();" />
<input type="button" value="CLOSE" onclick="$.magnificPopup.close();" />
<input type="button" value="CLOSE" onclick="$('pop').magnificPopup.close();" />
<a href="#" class="mpf-close">CLOSE</a>
<a href="#" onclick="magnificPopup.close();">CLOSE</a>
I read I need to place this code :
var magnificPopup = $.magnificPopup.instance;
But where ? in which page ? with what syntaxe ?
Magnific Popup documentation : LINK
Thanks for helping. Have a good day ;-)
Hope you can help me. I read and read again the documentation of Magnific Popup, but I'm not good enough with javascript.
1- I open a popup with this link :
<a href="mysubpage.html" class="pop">OPEN POPUP</a>
and this javascript :
$('.pop').magnificPopup({ type:'iframe', showCloseBtn : true, closeOnBgClick : true, midClick: true });
2- in my popup, I would like a button 'CLOSE' to close the pop-up.
I try this but it doesn't worked :
<input type="button" value="CLOSE" onclick="magnificPopup.close();" />
<input type="button" value="CLOSE" onclick="$.magnificPopup.close();" />
<input type="button" value="CLOSE" onclick="$('pop').magnificPopup.close();" />
<a href="#" class="mpf-close">CLOSE</a>
<a href="#" onclick="magnificPopup.close();">CLOSE</a>
I read I need to place this code :
var magnificPopup = $.magnificPopup.instance;
But where ? in which page ? with what syntaxe ?
Magnific Popup documentation : LINK
Thanks for helping. Have a good day ;-)
Share Improve this question asked Aug 3, 2014 at 14:27 KipkoolKipkool 432 silver badges4 bronze badges2 Answers
Reset to default 4The following will work. Add button (or any other element)
<button id="my-custom-close">close</button>
... and this javascript
$('#my-custom-close').click(function(){
//This will close popup dialog opened using $.magnificPopup.open()
$.magnificPopup.close();
});
There is an option to add a close button, and option to display inside popup. I would not use custom buttons or elements to try to close the popup, it should be included inside the popup once you have these two options set.
<a href='#' class='pop'>Open Popup</a>
$('.pop').magnificPopup({
// main options
showCloseBtn: true,
closeBtnInside: true,
gallery: {
// options for gallery
enabled: true
},
image: {
// options for image content type
titleSrc: 'title'
}
});
本文标签: javascriptjQuery magnificpopupcreate a button inside the popup to close the popupStack Overflow
版权声明:本文标题:javascript - jQuery magnific-popup : create a button inside the popup to close the popup - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742353762a2459007.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论