How can I exclude $(this) from a jQuery selector?
Try using the not()
method instead of the :not()
selector.
$(".content a").click(function() {
$(".content a").not(this).hide("slow");
});
You can use the not
function rather than the :not
selector:
$(".content a").not(this).hide("slow")
You can also use the jQuery .siblings()
method:
HTML
<div class="content">
<a href="#">A</a>
<a href="#">B</a>
<a href="#">C</a>
</div>
Javascript
$(".content").on('click', 'a', function(e) {
e.preventDefault();
$(this).siblings().hide('slow');
});
Working demo: http://jsfiddle.net/wTm5f/