div内容过长自动省略号

2015-11-21 0 294
div内容过长自动省略号
<div class="tits" style="width:900px;">${item.note}</div>
 
    //自动计算长度,并剔除html元素
    $(".tits").each(function(i) {
        var leg = 280;
        $(this).html($(this).text());
            var copyThis = $(this.cloneNode(true)).hide().css({
                'position': 'absolute',
                'width': 'auto',
                'overflow': 'visible'
            }); 
            $(this).after(copyThis);
            if(copyThis.width()>$(this).width()){
                $(this).html($(this).text().substring(0,leg)+'...');
                copyThis.remove();
            }else{
                copyThis.remove(); //清除复制
                return;
            }
    });

遇见资源网 js/jquery div内容过长自动省略号 http://www.ox520.com/11301.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务