<div class="reccommconbotright">
<img src="../img/zan.png" alt="" class="zan">
<span class="zannum">567</span>
</div>
// 点赞
var toggle = true;
$(".reccommconbotright img").click(function () {
var $likeNum = $(this).next('.zannum');
var num = +$likeNum.text()
if (toggle) {
$(this).attr("src", "../img/zaned.png")
toggle = false;
$likeNum.text(++num);
} else {
$(this).attr("src", "../img/zan.png")
toggle = true;
$likeNum.text(--num);
}
});
jquery实现点赞时数字增加,取消时数字减小
最新推荐文章于 2021-07-02 14:44:10 发布