Pergunta

http://isotope.metafizzy.co/docs/filtering.html

I am using isotope to filter some elements. I want to show/hide a button if that filter(from the navigation menu) is currently active:

jquery:

if($('nav.primary ul a').attr('.designs') == true){
        $(".loadMore").show();  
    }
else{$(".loadMore").hide();}

html:

<nav class="primary clearfix">
    <ul>
        <li><a href="#" class="selected" data-filter=".designs">Designs<span class="count">27</span></a></li>
        <li><a href="#" data-filter=".flash">Flash<span class="count">11</span></a></li>
    </ul>
</nav>
Foi útil?

Solução 2

Ok, I fixed it by doing:

$('nav.primary ul a').click(function(){
        var selector = $(this).attr('data-filter');
        if (selector !== ".designs"){
            $(".loadMore").hide();
        }
        else {
            $(".loadMore").show();
        }
    });

Outras dicas

The attribute name is data-filter, so i think your condition should be

if($('nav.primary ul a').attr('data-filter') == ".designs"){
    $(".loadMore").show();  
}
else{
    $(".loadMore").hide();
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top