2009-06-08 26 views

回答

6

对于在此搜索项目:

$(':visible, any-selector', this) 
$(this).find(':visible, any-selector') 

如果你想有一个真或假的回报:

if($(this).is(':visible, any-selector')){ 
    alert('this is visible, or matches "any-selector"'); 
    } 
else{ 
    alert('this is hidden, or doesn\'t match "any-selector"'); 
    } 
1

使用的语法如下:jQuery(expression, [context])

$(":contains(foo)", this) 
$(":visible", this) 
$("any-selector", this) 
+0

这是不正确的。它只会选择'this'的子元素。 – 2009-06-08 18:41:28

+0

jQuery(表达式,上下文)与jQuery(上下文).find(表达式)相同。 – Lathan 2009-08-27 20:57:43

3

这就是过滤器()方法是什么:

$(this).filter(":contains(foo)"); 
$(this).filter(":visible") 

根据文档:

Remo从匹配元素集合中找出与指定表达式不匹配的所有元素。