Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery 'this' keyword and selector's basic filters

Tags:

jquery

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)
like image 262
Christopher Altman Avatar asked Jun 08 '09 18:06

Christopher Altman


1 Answers

For Searching for items within this:

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

if you want a true or false return:

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"');
    }
like image 97
Ricardo C Avatar answered Sep 28 '22 01:09

Ricardo C