0
<ul id="component-list" class="no-left-margin">
    <li class="component-items hide">
        <span>Login</span>
            <a href="#">
            <i class="icon-remove"></i>
            </a>
    </li>
    <li class="component-items">
        <span>Register</span>
        <a href="#">
            <i class="icon-remove"></i>
        </a>
    </li>

</ul>

表示されているアイテムのリストを取得しようとしています(hideクラスのないliタグ内のスパンタグ)

$('.component-items span').not('.hide');

上記のセレクターは私に空の配列を与えています。

<li>Hideクラスなしでspanタグを取得するためのセレクターが必要です。

4

3 に答える 3

2
$('.component-items').not('.hide').find('span');
于 2012-08-15T17:45:19.163 に答える
0
$('.component-items:visible span')

http://api.jquery.com/visible-selector/

乾杯!

于 2012-08-15T17:46:23.710 に答える
0

css 疑似クラス :not() を使用するのが好きです。

$(".component-items").find("span:not(.hide)")

それがあなたを助けることを願っています

于 2014-01-20T14:52:25.633 に答える