开发者

How to get the trigger of a Fancybox?

I need to know which specific classes the anchor (which triggered the fancybox) has to do some more action wie the "onComplete"-function.

How do I get the trigger as jQuery-Object? $(this) seams to refer to the fancybox itself with no link to the original trigger.


Solution:

    $('a.fancybox').click(function(e){
    e.preventDefault();
    var trigger = $(this);
    $.fancybox({
        'href' : this.href,
        'onComplete' : function() {
            if (trigger.hasClass('specific_class')) {
                //do something
            } else {
                //do开发者_运维问答 something else or nothing
            }
        }
    });
});


Try something like:

  $("a").click(function(){
       var trigger = this;
       $.fancybox({
           href : this.href,
           onComplete : function() {
               if ( $(trigger).is(".someClass") ) {
                  // ...
               }
           }
       });
  });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜