我想弄清楚 LI 中的链接是否有一个类。我该怎么做呢?这是我到目前为止一直在尝试的:
(试图隐藏特定的li)
<a class="filtergallery" id="p" href="#">Portraits</a> <a class="filtergallery" id="n" href="#">Newborn</a> <a class="filtergallery" id="pe" href="#">Pets</a>
<ul class="portfolio-wrap">
<li><a class="p" href="#" title="First Pic"><img src="#" alt="First Pic" /></a></li>
<li><a class="pe" href="#" title="Second Pic"><img src="#" alt="Second Pic" /></a></li>
<li><a class="n" href="#" title="Third Pic"><img src="#" alt="Third Pic" /></a></li>
<li><a class="pe" href="#" title="Fourth Pic"><img src="#" alt="Fourth Pic" /></a></li>
jQuery:
$('.filtergallery').click(function(event){
var theid = $(this).attr('id');
$('.portfolio-wrap li').each(function(){
if (!hasClass(theid)) { // I need to see if the hyperlink inside the LI has this class...?
hide();
}
});
})