views:

41

answers:

1

Hi I have some tables in my page. The first row of each table is normal but the rest of the rows are hidden by giving the tr tag a class of hidden. There is a link in the first row to show more info (fade in the hidden rows) which currently uses this selector:

$(this).closest('tr').nextAll("tr.hidden").fadeIn()

However within the hidden rows there are some p tags with a class of hiddentext that I would like to select in order to do something to but I can't seem to get a selector working that does this. Iv tried doing things like:

$(this).closest('tr').nextAll("tr.hidden > p.hiddentext")
$(this).closest('tr').nextAll(".hidden").nextAll('td > p.hidden')

Can't get it to work though. Any help would be very much appreciated.

Thanks

+4  A: 

Try this:

$(this).closest('tr').nextAll(".hidden").find('p.hiddentext');

That would select all p.hiddentext inside the hidden rows. You can even chain the fadeIn() and selecting of p's in one command:

$(this).closest('tr').nextAll(".hidden").fadeIn().find('p.hiddentext').doSomething();
Tatu Ulmanen
THATS IT! Worked a charm thanks a lot you've been a great help to me :-)
geoffs3310
@user449568, don't forget to mark the answer as accepted if you found it useful.
Tatu Ulmanen