BTW: Möglicher Weise lässt sich das Ganze noch vereinfachen und übersichtlicher machen, wenn Du das HTML etwas anders arrangierst und jeweils eine Tiergruppe in einen übergeordneten Container legst:
HTML
<!doctype html>
<html>
<head>
<title>Test</title>
<script src="http://www.muench-herdecke.de/js/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function () {
$('.buttons a').click(function () {
$('.container').hide();
var sAttr = $(this).attr("data-filter");
if (sAttr == 'all')
$('.container').show();
else
$('.' + sAttr).show();
return false;
});
});
</script>
</head>
<body>
<h1>Filter:</h1>
<div class="buttons">
<a data-filter="all">alle Tiere</a>
I
<a data-filter="hund">Hund</a>
I
<a data-filter="katze">Katze</a>
I
<a data-filter="maus">Maus</a>
</div>
<section class="container hund">
<h2>Hunde</h2>
<h3>Hund 1</h3>
<h3>Hund 2</h3>
</section>
<section class="container katze">
<h2>Katzen</h2>
<h3>Katze 1</h3>
<h3>Katze 2</h3>
</section>
<section class="container maus">
<h2>Mäuse</h2>
<h3>Maus 1</h3>
<h3>Maus 2</h3>
</section>
</body>
</html>
Alles anzeigen