gpt4 book ai didi

jquery - 如何使用 jquery 查找 li.last 并添加 css

转载 作者:行者123 更新时间:2023-12-01 06:37:55 25 4
gpt4 key购买 nike

我有一个使用后面的代码以编程方式生成的无序列表,html 标记如下:

<ul>
<li></li>
<li>
<ul>
<li></li>
<li></li>
<li></li>
<li>last</li>
</ul>
</li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
<li></li>
<li>last</li>
</ul>
</li>
</ul>

问题是ul li ul li a 的样式为 border-bottom: Solid 1px White; 并且我想设置 border-bottom: none对于last sub li,是否可以使用jquery找到最后一个li然后修改类,或者有没有更好的方法来实现这样的目标谢谢

最佳答案

$('ul li ul li:last-child a').css('border-bottom', 'none');

选择最后一个li并更改其CSS border-bottom值,这使用:last-child selector , working example

CSS3您可以执行以下操作:

ul > li > ul > li:last-child a {
border-bottom: none;
}

Working example using CSS3

关于jquery - 如何使用 jquery 查找 li.last 并添加 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9688815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com