开发者

jQuery - Select EVERY UL of last LI in list

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


Try:

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

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


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

Note that there are compatibility issues with CSS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜