jq限制字符个数

<script>
$(document).ready(function () {
//限制字符个数
$(".box-right .title a").each(function () {
var maxwidth = 23;
if ($(this).text().length > maxwidth) {
$(this).text($(this).text().substring(0, maxwidth));
$(this).html($(this).html() + '...');
}
});
});
</script>

posted @ 2016-10-19 13:42  rickon  阅读(322)  评论(0编辑  收藏  举报