layui table表格字段过长,展示不完整时,鼠标放到上面展示完整信息

1、首先每个列都有一个title,里面放入完整信息,然后写一个如下的function,

1
2
3
4
5
6
7
8
function tdTitle(){
     $( 'th' ).each( function (index,element){
         $(element).attr( 'title' ,$(element).text());
     });
     $( 'td' ).each( function (index,element){
         $(element).attr( 'title' ,$(element).text());
     });
};

  2、在table数据渲染完的回调done中调用刚才写的function

1
2
3
4
5
6
7
8
9
10
table.render({
   cols:  [[ //标题栏
     {checkbox: true }
     ,{field: 'id' , title: 'ID' , width: 80}
     ,{field: 'username' , title: '用户名' , width: 120}
   ]]
   ,done: function (res){
         tdTitle();
     }
});

猜你喜欢

转载自www.cnblogs.com/uzxin/p/12090342.html