我有一系列缩略图。默认情况下,一个应用了一个事件类“p7_current”,它在该图像周围放置了一个边框。其他人都有一个删除边框的“p7_inactive”类。
如果在这组 6 个拇指中,最后一个点击的拇指具有“p7_current”类,其余的被分配为“p7_inactive”,我会喜欢。
我如何使用 jquery 解决这个问题?
<div class="p7_postcard_thumbs">
<a href="#" target="p7_postcard_iframe"><img src="images/p7_pc1.jpg" class="p7_current" /></a>
<a href="#" target="p7_postcard_iframe"><img src="images/p7_pc2.jpg" class="p7_inactive" /></a>
<a href="#" target="p7_postcard_iframe"><img src="images/p7_pc3.jpg" class="p7_inactive" /></a>
<a href="#" target="p7_postcard_iframe"><img src="images/p7_pc4.jpg" class="p7_inactive" /></a>
<a href="#" target="p7_postcard_iframe"><img src="images/p7_pc5.jpg" class="p7_inactive" /></a>
<a href="#" target="p7_postcard_iframe"><img src="images/p7_pc6.jpg" class="p7_inactive" /></a>
</div>
最佳答案
$('.p7_postcard_thumbs img').click(function(e){
$('.p7_postcard_thumbs img').removeClass('p7_current p7_inactive').not(this).addClass('p7_inactive');
$(this).addClass('p7_current');
});
关于javascript - 单击更改拇指组的类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11317954/