fancybox , get clicked id from a bunch of links
$("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>') ;
});
});
});
精彩评论