【jquery】实现文字截断显示

$(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>
原文地址:https://www.cnblogs.com/enone/p/2746204.html