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>
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();
}
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();
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.