jquery控制内容的数量,多余的内容显示。。。

<script type="text/javascript">
$(document).ready(function(){
//限制字符个数
$(".contents").each(function(){   //contents 是标签
var maxnum=3;
if($(this).text().length>maxnum){
$(this).text($(this).text().substring(0,maxnum));
$(this).html($(this).html()+'...');
}
});
});
</script>

猜你喜欢

转载自blog.csdn.net/weixin_38615720/article/details/79896596