html table td 固定长度隐藏文字 鼠标进入显示悬浮文字

一.在td的长度范围内要显示大量内容时,为了不破坏布局,只能显示该长度的文字,超过的的文字隐藏。
1.table 表中一定要设置 style="table-layout: fixed;"
<table id="contentTable" class="table table-striped table-bordered table-condensed" style="table-layout: fixed;">

2.在td 中设置:style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis"

<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis"   οnmοusemοve="removeClassType(this)">

3.鼠标进入悬浮显示,其实就是将内容赋值给标题属性。

onmousemove:鼠标进入事件

<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis" οnmοusemοve="removeClassType(this)">

js:将td内的内容赋值给 title:标题内容

function removeClassType($this) {
    $($this).attr("title",$this.innerText);
}
  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值