AlexTCGPro AlexTCGPro - 4 months ago 7
jQuery Question

Toggling one element disables the others

So I have this code http://jsfiddle.net/GqS7W/

$(document).ready(function(){
$(".toggler").click(function(e){
e.preventDefault();
$('.cat'+$(this).attr('data-prod-cat')).toggle();
}); });


And I applied it to my table, but I need that when one button is pressed the others hide, like a menu, how can I do that?

Answer

This should work

$(document).ready(function(){
    $(".toggler").click(function(e){
        e.preventDefault();
        $('tr[class^=cat]').hide();
        $('.cat'+$(this).attr('data-prod-cat')).show();
    });
});
Comments