<div class="buttons"> <a id="showall">All</a> <a class="showSingle" target="1">Morning</a> <a class="showSingle" target="2">APM</a> <a class="showSingle" target="3">Night</a> </div> <div id="div1" class="targetDiv">Lorum Ipsum1</div> <div id="div2" class="targetDiv">Lorum Ipsum2a</div> <div id="div2" class="targetDiv">Lorum Ipsum2b</div> <div id="div3" class="targetDiv">Lorum Ipsum3</div>
$('.showSingle').click(function(){ var self = $(this); $('.targetDiv').hide(); $('.targetDiv[id=div' + self.attr('target') +']').show(); });