STYLE SWITCHER

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>

<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();
});

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.

  • Keep your skills sharp, get informed.

    Subscribe to our mailing list and get interesting stuff and updates to your email inbox