zoukankan      html  css  js  c++  java
  • div内容过长自动省略号

    <div class="tits" style="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;
                }
        });

     

  • 相关阅读:
    Document
    Document
    Document
    Document
    Document
    Document
    Document
    Document
    8.React 组件封装
    window.location / history / 以及相关事件
  • 原文地址:https://www.cnblogs.com/telwanggs/p/5305576.html
Copyright © 2011-2022 走看看