views:

64

answers:

4

Hello.

$(".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.

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>
+5  A: 
$('.navigation > ul > li a')
meder
A: 

Maybe this will work

$(".navigation a").not("ul ul a").hover(function(){
});
Victor Vostrikov
+3  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

Marius
A: 

Try this:

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