开发者

jQuery .not() function, not working

$(".navigation a").not(".navigation ul ul a").hover(function(){

    // Not working.

});

For some reason, ALL <a> elements inside .navigation still get the hover function assigned to it.开发者_如何学C

I only want the elements that are not inside ul ul.

The Html is structured like this:

<div class="navigation">
    <ul>
        <li><a>item 1</a></li>
        <li><a>item 2</a></li>
        <li>
            <a>item 3</a>
            <ul>
            <li><a>item 3.1</a><li>
            <li><a>item 3.2</a><li>
            <li><a>item 3.3</a><li>
            </ul>
        </li>
        <li><a>item 4</a></li>
        <li><a>item 5</a></li>
    </ul>
</div>


$('.navigation > ul > li a')


try

$(".navigation>ul>li>a");

This will select anchors that are direct descendants of li's which are direct descendants of ul which are direct descendants of .navigation


Maybe this will work

$(".navigation a").not("ul ul a").hover(function(){
});


Try this:

$(".navigation a").not("ul ul a").hover(function(){ });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜