本文分享使用jQuery遍历所有“展开更多”按钮 实现展开收起功能
主要js:
<script type="text/javascript">
$(function () {
$(".listr").each(function () {
var listr = $(this);
$(this).find("a").click(function () {
var height = listr.next(".listl").css("height");
if (height != $(this).parents(".lists").css("height")) {
$(this).parents(".lists").animate({ height: height });
listr.animate({ height: height });
$(this).text("点击收起");
} else {
$(this).parents(".lists").animate({ height: "90px" });
listr.animate({ height: "90px" });
$(this).text("点击展开");
}
})
})
})
</script>
