JQuery 'this' basic keyword and selector filters

When using the < this " keyword in jQuery, what is the syntax for adding basic filters.

For example:

$(this):contains('foo')

$(this):visible OR $(this:visible)
+5
source share
3 answers

To search for items in this field:

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

if you want to return true or false:

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"');
    }
+6
source

That the filter () method is intended to:

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

According to the docs:

Removes all elements from the set of matched elements that do not match the specified expression (s).

+3
source

use this syntax: jQuery( expression, [context] )

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

All Articles