开发者

jQuery - Select EVERY UL of last LI in list

开发者 https://www.devze.com 2023-01-05 10:29 出处:网络
I\'m trying to format my list of items, where the html goes like this: <ul class=\'product_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

精彩评论

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