【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>
posted @ 2012-10-30 13:50  Younger  阅读(1049)  评论(0编辑  收藏  举报