views:

11014

answers:

2

Hi.

I have something like this:

<div class="content">
    <a href="#">A</a>
</div>
<div class="content">
    <a href="#">B</a>
</div>
<div class="content">
    <a href="#">C</a>
</div>

When one of these links is clicked, I want to perform the .hide() function on the links that are not clicked. I understand jQuery has the :not selector, but I can't figure out how to use it in this case because it is necessary that I select the links using $(".content a")

I want to do something like

$(".content a").click(function()
{
    $(".content a:not(this)").hide("slow");
});

but I can't figure out how to use the :not selector properly in this case.

+21  A: 

Try using the not() method instead of the not() selector.

$(".content a").click(function() {
    $(".content a").not(this).hide("slow");
});
Dan Herbert
+3  A: 

You can use the not function rather than the :not selector:

$(".content a").not(this).hide("slow")
Zach Langley