您的位置:首页 > Web前端 > JQuery

【jquery】实现文字截断显示

2012-10-30 13:50 232 查看
$(function() {
$("[class^='TextCut']").each(function() {
var cutlength = parseInt($(this).attr('class').replace("TextCut", ""));
var text = $(this).html().trim();
$(this).attr("title", text);
text = (text.length > cutlength + 2) ? (text.substring(0, cutlength) + "...") : text;
$(this).html(text);
});
});


<a href="#" class="TextCut12">
利用jquery实现链接文字截断显
</a>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: