开发者

fancybox, return value from clicked element

开发者 https://www.devze.com 2023-01-04 14:33 出处:网络
I have a quick question, (I hope it is quick one). I have fancybox plugin (jquery) -- http://fancybox.net/

I have a quick question, (I hope it is quick one).

I have fancybox plugin (jquery) -- http://fancybox.net/

             $(".Sets a").fancybox({
                  'onComplete'          : function(){
                                   $('#fancybox-inner').prepend('<a href="#">'+ **clicked element rel** +'</a>')}
            });

There is a right way, to take this value, in my head now I can see , just to add a class for clicked element, at with this class can help me to detect which element was clicked.

Will be awesome to have something like

$(".Sets a").fancybox({
              'onComplete'          : function(){
                               $('#fancybox-inner').prepend('<a href="#">'+ $(this).a开发者_Python百科ttr("rel") +'</a>')}
        });

Thank you !!!


To get the $(this) you need to add a click handler to it.

Call your fancybox this way:

$('.Sets a').click(function(){
    var _this = $(this);
    $.fancybox({
        'onComplete':function(){
            $('#fancybox-inner').prepend('<a href="#">'+ _this.attr("rel") +'</a>');
        }
    })
});
0

精彩评论

暂无评论...
验证码 换一张
取 消