在多个选择中选择$(this)中的元素

时间:2013-05-07 10:25:38

标签: jquery jquery-selectors

我正在尝试在以下函数中选择一个元素:

  $('.reply-comment').live('click', function(){
if( $(this).parents('.element_footer').find('.reply, .send-reply').is(':hidden') ){
  $(this).parents('.element_footer').find('.reply, .send-reply').slideDown('fast');
}else if( $(this).parents('.element_footer').find('.reply, .send-reply').is(':visible') ){
  $(this).parents('.element_footer').find('.reply, .send-reply').slideUp('fast');
}
return false;

});

之后:.find('.reply, .send-reply').slideDown('fast')我会将.focus()链接到.reply元素

如何从$(this)中选择它?

1 个答案:

答案 0 :(得分:2)

使用.filter()

  

描述:将匹配元素集合减少到与选择器匹配的元素或通过函数测试。

$(this).filter('.reply');