You wouldn’t even need something like :not, just do the Hide and then the show just for the selected one, like this:
$(".link").click(function(event) {
$(".link").hide();
$(this).show();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div>
<a class="link">Link 1</a>
<a class="link">Link 2</a>
<a class="link">Link 3</a>
<div>
Now if you use with jQuery-ui and animations from it the effect will make it disappear and show this, which may even look like a bug, in this specific case you could just use the . filter so:
$(".link").click(function(event) {
var $this = this;
$(".link").filter(function (index, element) {
return element !== $this;
}).hide();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div>
<a class="link">Link 1</a>
<a class="link">Link 2</a>
<a class="link">Link 3</a>
<div>
Or even easier, using the . not, like this:
$(".link").click(function(event) {
$(".link").not(this).hide();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div>
<a class="link">Link 1</a>
<a class="link">Link 2</a>
<a class="link">Link 3</a>
<div>
The filter would be more interesting for a more complex filtering, for your case . not already solves.
jQuery API:
WOW! Three ways! Thank you @Guilhermenascimento.
– Thiago Krempser