If you use javascript to set when the article paragraph exceeds two lines, the showMore button will appear.
If there are no more than two lines, showMore will not be displayed. At present, I use the word count method to set a problem, that is, it has more than two lines. It's OK, but the number of words has not reached 40, so the showMore button will not appear. I want to use the number of lines to judge, but how should I write it?
$(function(){
let len = 40;
$('.info_content').each(function(){
if($(this).html().trim().length >len){
var str=$(this).html().substring(0,len-1)+"<button class='info-more'>...showMore</button>";
$(this).html(str);
}
});
});
.info_content{
width: 250px;
font-size: 15px;
letter-spacing:1px;
line-height: 1.5;
margin-bottom: 8px;
letter-spacing:0;
overflow:hidden;
text-overflow:clip;
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:2;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h3 class="info_content">
asd asdasdasd asd asda sdasd asdasd asd asdsda sdasdasda sdasd asda sdasd asd a
</h3>
<h3 class="info_content">
asdasdasddsasfsdfsdfsdfsdf
</h3>
<!-- 第三組 -->
<h3 class="info_content">
asdasdasdasgasdasdas asdasda
asdasdasdasdasdasdasdasdasdd asdasdasdasdasdasdasdasda
asdasdasdasdasdasdas asdasdaasd asda
</h3>