Show / hide same div id with jquery

<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 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>
    var self = $(this);
    $('.targetDiv[id=div' + self.attr('target') +']').show();

Recent Article

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.