我必须在元素('.fav')的jQuery集中单击元素的父节点。 有没有人有任何建议,我该怎么做?jQuery - 排除被单击元素的父节点
$('.fav .favFrame').click(function(){
$('.fav').fadeOut(400); //exclude the .fav that child .favFrame was clicked here
});
THX
我必须在元素('.fav')的jQuery集中单击元素的父节点。 有没有人有任何建议,我该怎么做?jQuery - 排除被单击元素的父节点
$('.fav .favFrame').click(function(){
$('.fav').fadeOut(400); //exclude the .fav that child .favFrame was clicked here
});
THX
使用.not()
:
$('.fav .favFrame').click(function(){
$('.fav').not($(this).parent()).fadeOut(400); //exclude the .fav that child .favFrame was clicked here
});
试试这个:
$('.fav .favFrame').click(function(){
var notThis = $('.fav').not($(this).parent());
notThis.fadeOut(400); //fade all except this parent
});
'.not()'采用参数 – bpierre 2011-04-15 13:23:16
$('.fav .favFrame').click(function() {
var myParent = $(this).closest('.fav');
$('.fav').not(myParent).fadeOut(400);
});
这样,你不想淡出没有得到在所有受影响的元素。
你的意思是,让类“fav”的所有元素都淡出,而元素是已被点击的类“favFrame”的元素的父元素? – Hannes 2011-04-15 13:18:27