如何添加一些自定义CSS的最后一个孩子只有可见与Jquery?

如何添加一些自定义CSS的最后一个孩子只有可见与Jquery?

问题描述:

我允许用户将列表的一部分隐藏/可见等。

I am allowing users to make parts of a list hidden/visible etc.

现在这里是我的列表:

基本列表,但最终列表项有一些自定义CSSborder-bottom:none - 只是为了更好一点。

Basic list, but the very end list item has some custom CSS "border-bottom: none" - just to make it a bit more nicer looking.

<ul>
      <li class="item">Item</li>
      <li class="widget">widget</li>
      <li class="item">Item</li>
      <li class="item">Item</li>
      <li class="widget">Widget</li>
      <li class="widget">Widget</li>
</ul>

当我使用最后 添加一些自定义CSS,它工作完美。我的问题是当我隐藏窗口小部件,它们被隐藏的意图,但自定义CSS被使用,因为这些是隐藏的,边框仍然显示。

When I use the last selector, to add some custom CSS, it works perfect. My problem is when I hide the widgets, they are hidden as intended, but the custom CSS is used on this and as these are hidden, the border still shows up.

使用可见 :visibleselector:

use the ":visible" selector:

$("li:visible:last").css("your css rules");