[jQuery] Re: Trouble selecting a P inside a repeating DIV

2009-04-29 Thread Ricardo
The nth-child index is relative to the whole collection of children elements, not just the one you're selecting. With your new mark-up you're better off doing this: $(".insidepost ul + p") //or $(".insidepost p:first") .addClass("caminfo") .next('p').addClass("cambuy") .next('p').addC

[jQuery] Re: Trouble selecting a P inside a repeating DIV

2009-04-29 Thread Tobias
Perfect. But just for future helpfulness of anyone coming across this post- I simplified my code above, it actually looks like > > Blah Blah Blah item 1 item 2 item 3 > > paragraph 1 > > paragraph 2 > > paragraph 3 > > As a consequence I need to use $(".insidepost p:nth-child(3)").addClass

[jQuery] Re: Trouble selecting a P inside a repeating DIV

2009-04-28 Thread Ricardo
That's because eq() filters the whole collection of Ps from all DIVs. Use nth-child instead (indexes start at 1 instead of 0): $(".insidepost p:nth-child(1)").addClass("cambottomline"); $(".insidepost p:nth-child(2)").addClass("cambuy"); cheers, - ricardo On Apr 28, 10:15 pm, Tobias wrote: > H