table <td>显示部分内容鼠标悬停显示全部的实现方法

一,引入layer.js插件(脚本文件);

二,自己在代码中添加脚本代码:

    

//描述鼠标悬停显示全部内容
$(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
            });
        }
    });
})
三,根据自己的喜好或者需求来改变显示的样式即可。

猜你喜欢

转载自blog.csdn.net/qq_19167629/article/details/80135065