jQuery-Fancybox和回调 [英] Jquery - fancybox and callback

查看:90
本文介绍了jQuery-Fancybox和回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对fancybox有问题.
我想编写一个在fancybox打开时运行的函数.如何以及何时调用该函数?

I have problem with fancybox.
I want to write a function that will run when the fancybox opened. How and when to call the function?

示例:

function myFunc() {
    alert("Opened!");
}

$('.content a').fancybox({ 
    'hideOnContentClick': false ,
    'callBackOnShow': myFunc(), // This not working! It call function when page is loaded
    'frameWidth': 920,
    'frameHeight': 530
});

推荐答案

使用myFunc代替myFunc().在javascript中,带有parens(和/或args)的函数表示您要调用它.没有它们的函数名称意味着您只想引用该函数(这可能就是fancybox想要的)

Instead of myFunc() use myFunc. In javascript, a function with parens (and/or args) means you want to call it. A function name without them means you just want a reference to that function (which is probably what fancybox wants from you)

这篇关于jQuery-Fancybox和回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆