开发者

fancybox, return value from clicked element

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜