Reputation: 1642
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>
Upvotes: 0
Views: 1457
Reputation: 1642
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();
}
});
Upvotes: 0
Reputation: 2676
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();
}
Upvotes: 1