鼠标悬停显示td全部内容

一般当table的某字段内容溢出,会以省略号代替显示。为何能知道该字段栏的完整信息。可用以下方法实现:

在代码中添加脚本代码:

//描述鼠标悬停显示全部内容
$(function () {
    $("td").on("mouseenter",function() {
        if (this.offsetWidth < this.scrollWidth) {
            var that = this;
            var text = $(this).text();
            layer.tips(text, that,{
                tips: 1,
                time: 2000         //设置显示时间
            });
        }
    });
});

 

你可能感兴趣的:(前端)