Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select the .next() element with a specific attribute JQUERY

This is what I have :

$("#comment").next().attr('shown',0).fadeIn();

I'm trying to show the next comment that is hidden on the page. however, I'm trying to do two comments shown at a time, so if you click the first one, the second one is next. So I've given a shown attribute. I would like to select the NEXT with the attribute shown=0. The above does not work. I believe it would be next(tr[shown=0]) but i can't get that to work (i'm in a table looking for the next row)

any help is appreciated!

like image 645
corbinan Avatar asked Jul 25 '11 23:07

corbinan


1 Answers

next can only return the immediate next sibling.

You can call nextAll, which returns all subsequent siblings, with the :first selector to get the first matching one:

$(...).nextAll("tr[shown=0]:first")
like image 144
SLaks Avatar answered Nov 17 '22 10:11

SLaks