在jQuery中使用'这个'关键字时,添加基本过滤器的语法是什么。jquery'this'关键字和选择器的基本过滤器
例如:
$(this):contains('foo')
$(this):visible OR $(this:visible)
在jQuery中使用'这个'关键字时,添加基本过滤器的语法是什么。jquery'this'关键字和选择器的基本过滤器
例如:
$(this):contains('foo')
$(this):visible OR $(this:visible)
对于在此搜索项目:
$(':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"');
}
使用的语法如下:jQuery(expression, [context])
$(":contains(foo)", this)
$(":visible", this)
$("any-selector", this)
这就是过滤器()方法是什么:
$(this).filter(":contains(foo)");
$(this).filter(":visible")
根据文档:
Remo从匹配元素集合中找出与指定表达式不匹配的所有元素。
这是不正确的。它只会选择'this'的子元素。 – 2009-06-08 18:41:28
jQuery(表达式,上下文)与jQuery(上下文).find(表达式)相同。 – Lathan 2009-08-27 20:57:43