Javascript特效之评论删除效果

Javascript特效之评论删除效果

今天来看看怎么实现类似wordpress的评论删除效果。

效果图:


点击delete 整个内容会隐藏掉。

实现思路:

使用jquery动画功能animate先改变元素背景颜色后再把元素的可见度opacity 设置为隐藏。

jquery代码:

$(".pane:even").addClass("alt");

	$(".pane .btn-delete").click(function(){
		alert("This comment will be deleted!");
		
		$(this).parents(".pane").animate({ backgroundColor: "#fbc7c7" }, "fast")
		.animate({ opacity: "hide" }, "slow")
		return false;
	});

	$(".pane .btn-unapprove").click(function(){
		$(this).parents(".pane").animate({ backgroundColor: "#fff568" }, "fast")
		.animate({ backgroundColor: "#ffffff" }, "slow")
		.addClass("spam")
		return false;
	});

	$(".pane .btn-approve").click(function(){
		$(this).parents(".pane").animate({ backgroundColor: "#dafda5" }, "fast")
		.animate({ backgroundColor: "#ffffff" }, "slow")
		.removeClass("spam")
		return false;
	});

	$(".pane .btn-spam").click(function(){		
		$(this).parents(".pane").animate({ backgroundColor: "#fbc7c7" }, "fast")
		.animate({ opacity: "hide" }, "slow")
		return false;
	});

.pane:even作用是选择每个带有偶数 index 值的元素

猜你喜欢

转载自blog.csdn.net/a271720559/article/details/80850420