码迷,mamicode.com
首页 > 其他好文 > 详细

在一个表格里,超过一定宽度字符串进行截取显示点点,鼠标移上去显示全

时间:2015-12-08 16:04:40      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

    <table  style="width:100%" >
                            <tr>
                                <th  style="width:30%">相关通用药物分类</th>
                                <th  style="width:35%">用药目的(非交集用颜色区分)</th>
                                <th  style="width:15%">交集类别</th>
                                 <th  style="width:15%">操作</th>
                            </tr>
                          <tr>
                              <td field="name"><div class="z_cutout">xxxxxxxxxxxxxxxxxxxxxsssxxxxxxxxxxxxxxxxxxxxssssssssssss</div></td>
                              <td field="jindu">xxx</td>                          
                              <td field="time">包含</td>
                              <td field="opear">
                                 <a href="#" class="z_a">删除关联</a>
                              </td>
                          </tr>
                          <tr>
                              <td field="name"><div class="z_cutout">xxxxxxxxxxxxxxxxxxxxxsssxxxxxxxxxxxxxxxxxxxxssssssssssss</div></td>
                              <td field="jindu">xxx</td>                          
                              <td field="time">包含</td>
                              <td field="opear">
                                 <a href="#" class="z_a">删除关联</a>
                              </td>
                          </tr>

</table>

 

 

$(function(){
            $(".z_cutout").each(function(i) {
                if($(this).text().length>10){
                    $(this).attr("title",$(this).text());
                    var text = $(this).text().substring(0,10)+"...";
                    $(this).text(text);
                }
            });
            
            $(".z_cutout").mouseenter(function()
                { //鼠标移入
                    var title  = $(this).attr("title");
                    $(this).text(title);
                }).mouseleave(function()
                { //鼠标移出
                    if($(this).text().length>10){
                    var text = $(this).text().substring(0,10)+"...";
                    $(this).text(text);
                   }
                });
        });

 

在一个表格里,超过一定宽度字符串进行截取显示点点,鼠标移上去显示全

标签:

原文地址:http://www.cnblogs.com/jsingleegg/p/5029265.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!