使用CSS和JQuery实现表格单元格内容超出时部分隐藏,隐藏部分以...显示

1.使用CSS实现,给此单元格添加一个Class:

width:130px;
display:block;
overflow:hidden;
word-break:keep-all;
white-space:nowrap;
text-overflow:ellipsis;

2.使用JQuery实现,表格id="projectName":

$("[id='projectName']").each(function(){
                var _self = $(this);
                var text = _self.text();
                text = text.substring(0,15) + "...";
                _self.html(text);
            });

 

posted @ 2017-05-10 21:05  梦里南柯  阅读(356)  评论(0编辑  收藏  举报