views:

41

answers:

2

Hello,

I'm trying to format my list of items, where the html goes like this:

<ul class='product_list'>
<li>Item 1
    <ul>
        <li>Item 1.1</li>
        <li>Item 1.2
            <ul>
                <li>Item 1.2.1</li>
                <li>Item 1.2.2
                    <ul>
                        <li>Item 1.2.2.1</li>
                        <li>Item 1.2.2.2</li>
                    </ul>
                </li>
            </ul>
        </li>
        <li>Item 1.3</li>
    </ul>
</li>
<li>Item 2</li>

And so on, hope you get the idea, that it can go deep infinet amout of times and now, I need to select and format UL of every LAST LI in any UL of the list.

Do you have any idea? I've been stuck on this for 2 days now and all that I come up with has some "but", when it does't work. =/

Mike

+2  A: 

Try:

$("li:last-child > ul").css("border", "1px solid red");

Demo: http://jsfiddle.net/2NVB7/

karim79
Thanks, this is it. :-)
Mike
A: 

CSS/jQuery selector: li:last-child > ul

Note that there are compatibility issues with CSS.

Steven Xu