首页 > 其他 > 详细

各种前端事件

时间:2017-01-12 08:12:12      阅读:200      评论:0      收藏:0      [点我收藏+]

显示指定个数的字,多出的部分显示省略号

方式一:简单粗暴

  显示前十个字符,后面的是省略号

{{ user_info.username | truncate(10) }} 

方式二:老老实实写 css && js

css样式:

.slb{
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        width: 80px;
    }

html页面:

<tr>
    <td class="user_defined slb">
        <span style="text-align: center" onmouseout="miss(this)" onmousemove="appear(this)" ondblclick="add_check(this)">{{ info.username.0 }}</span>
        <span hidden>{{ info.uid }}</span>
        <span hidden>{{ info.profit }}</span>
   </td>
</tr>

下面是js

function appear(ths) {
  $(ths).parent().removeClass(‘slb‘)
        }
function miss(ths) {
  var has_class = $(ths).parent().hasClass(‘slb‘);
  if (has_class){
    $(ths).parent().removeClass()
  }else {
    $(ths).parent().addClass(‘slb‘)
   }
}

  

 

各种前端事件

原文:http://www.cnblogs.com/mosson/p/6272755.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!