在jQuery中使用' this '关键字时,添加基本过滤器的语法是什么.
例如:
$(this):contains('foo')
$(this):visible OR $(this:visible)
Run Code Online (Sandbox Code Playgroud)
用于搜索此内的项目:
$(':visible, any-selector', this)
$(this).find(':visible, any-selector')
Run Code Online (Sandbox Code Playgroud)
如果你想要一个真或假的回报:
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"');
}
Run Code Online (Sandbox Code Playgroud)