jQuery截取超出字符串,并用省略号代替

$(function () {
    /***************************
    截取标签内字符串长度公用方法   
    ***************************/
    jQuery.each(jQuery("[split]"), function (i) {
        //获得截取长度   
        var toLength = parseInt($(this).attr("split"));
        if (jQuery.trim(this.innerHTML).length > toLength) {
            this.title = this.innerHTML;
            this.innerHTML = jQuery.trim(this.innerHTML).substring(0, toLength) + "......";
        }
    });
});
 <span split="20"><%#Eval("片名") %></span>
原文地址:https://www.cnblogs.com/mane/p/2720736.html