开发者

fancybox , get clicked id from a bunch of links

开发者 https://www.devze.com 2023-03-28 01:59 出处:网络
$(\"a.addEditPost\").each(function() { $(this).fancybox({ \'overlayShow\' : true, \'hideOnOverlayClick\' : false,
$("a.addEditPost").each(function() {

    $(this).fancybox({
       'overlayShow' : true,
        'hideOnOverlayClick' : false,
        'hideOnContentClick' : false,
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'content' : $('.cntPost').prepend('<a href="#">'+this.id+'</a>')        
    });
})

hi ! how is possible to get id from 开发者_运维技巧the element i clicked , and than to send to fancybox , right now i'm getting just all id's .But i need just clicked id . THANKS A LOT FOR Helping


The easiest probably would be to write a handler for click event on whatever you are calling a fancybox, then assign it to a variable, and mannually call fancybox. In such case you should be able to access the variable fom inside fancybox setup. Below is a concept code:

$("a.addEditPost").each(function() {
 $id=$(this);
 $(id).click(function(){
  var i_am_clicked=this;
  $id.fancybox({overlayShow' : true,
    'hideOnOverlayClick' : false,
    'hideOnContentClick' : false,
    'transitionIn'  :   'elastic',
    'transitionOut' :   'elastic',
    'content' : $('.cntPost').prepend('<a href="#">'+i_am_clicked.id+'</a>') ;       
    });
});
});
0

精彩评论

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

关注公众号