Try this.

Given the following HTML:
<div id="book">
        <div class="page">
                <p>Paragraph one, page one</p>

                <p>Paragraph two, page one</p>

                <p>Paragraph three, page one</p>
        </div>
        <div class="page">
                <p>Paragraph one, page two</p>

                <p>Paragraph two, page two</p>

                <p>Paragraph three, page two</p>
        </div>
        <div class="page">
                <p>Paragraph one, page three</p>

                <p>Paragraph two, page three</p>

                <p>Paragraph three, page three</p>
        </div>
        <div class="page">
                <p>Paragraph one, page four</p>

                <p>Paragraph two, page four</p>

                <p>Paragraph three, page four</p>
        </div>
        <div class="page">
                <p>Paragraph one, page five</p>

                <p>Paragraph two, page five</p>

                <p>Paragraph three, page five</p>
        </div>
</div>

The following jQuery code should do the trick:
$("#book .page").each(function() {
        $("p:first",this).css("backgroundColor","yellow");
});

The result of five minutes messing about, it seems to do what you're after but I'm sure it can be improved upon.

Regards,
Michael Price

Reply via email to