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 <tobi...@gmail.com> wrote:
> Hello - My basic code is something like
>
> <div class="insidepost">
> <p>paragraph 1</p>
> <p>paragraph 2</p>
> <p>paragraph 3</p>
> </div>
>
> <div class="insidepost">
> <p>paragraph 1</p>
> <p>paragraph 2</p>
> <p>paragraph 3</p>
> </div>
>
> I was hoping to use
>
>                 $(".insidepost p:eq(1)").addClass("cambottomline");
>
>                 $(".insidepost p:eq(2)").addClass("cambuy");
>
> Only works on the first div though.  Any suggestions for selecting the
> same certain P in each div?
>
> Thank you,
> Tobias

Reply via email to