jQuery FancyBox 自定义关闭按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8398278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FancyBox custom close button
提问by Roukmoute
I want to set up buttons types that can close the window, so I made wrote this code:
我想设置可以关闭窗口的按钮类型,所以我写了这段代码:
$(".fstandard").fancybox({
afterClose: function() {
alert("Closed!");
},
afterShow : function() {
$(':button').click(function() {
$.fancybox.close();
})
}
});
I tried in vain several other codes, but none of them worked, the window does not close. This line gives me an error:
我尝试了其他几个代码,但没有一个成功,窗口没有关闭。这一行给了我一个错误:
$.fancybox.close();
$.fancybox is undefined
$.fancybox 未定义
I use FancyBox v2.0.3. In their documentation, it is well presented to close the window: http://fancyapps.com/fancybox/#support
我使用 FancyBox v2.0.3。在他们的文档中,很好地关闭了窗口:http: //fancyapps.com/fancybox/#support
Thanks in advance
提前致谢
回答by Rory McCrossan
It says in the documentation:
它在文档中说:
To use from inside the iframe -
<a href="javascript:parent.$.fancybox.close();">Close me</a>
要从 iframe 内部使用 -
<a href="javascript:parent.$.fancybox.close();">Close me</a>
Have you tried:
你有没有尝试过:
$(':button').click(function() {
parent.$.fancybox.close();
})