Jquery - fancybox and callback

前端 未结 7 1668
借酒劲吻你
借酒劲吻你 2020-12-31 17:36

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?

Example:

func         


        
7条回答
  •  太阳男子
    2020-12-31 17:54

    It should be:-

    function myFunc() {
        alert("Opened!");
    }
    
    $('.content a').fancybox({ 
        'hideOnContentClick': false ,
        'callBackOnShow': myFunc, // no brackets
        'frameWidth': 920,
        'frameHeight': 530
    });
    

    Or, you can make an anonymous function...

    $('.content a').fancybox({ 
        'hideOnContentClick': false ,
        'callBackOnShow': function() { alert('hello'); },
        'frameWidth': 920,
        'frameHeight': 530
    });
    

提交回复
热议问题