<div class="content">里面是数据</div><div class="show_all_content">查看全文</div>
.content.line {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
.content {
margin-top: .2rem;
line-height: .35rem;
}
.show_all_content{
display:none;
}
$.each($("ul li"), function (inx, val) {
var $obj = $(this).find('.content')
var scrollHight = $obj[0].scrollHeight;
var clientHeight = $obj[0].clientHeight;
if (scrollHight > clientHeight) {
$obj.next().children(".show_all_content").show()
}
});
$("ul li .show_all_content").click(function () {
if ($(this).text() == '查看全文') {
$(this).prev().removeClass('line');
$(this).text('收起全文');
} else {
$(this).prev().addClass('line');
$(this).text('查看全文');
}
})