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();
     }
});


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM