1,设置css样式

<style>
table {
width: 100%;
float: left;
table-layout:fixed;
width:600px;
border:1px solid #ccc;
 }

table tr {
    line-height: 25px;
    border:1px solid #ccc;
}

 table td {
     border:1px solid #ccc;
     text-align:center;
 }
.mhover{
     border:1px solid #ccc;
     white-space:nowrap;
     text-overflow:ellipsis;
     overflow:hidden;
 }
</style>

 

2,js设置click和mousemove和mouseout事件

<script>
$(document).ready(function () {
        $(“.mall”).hide();
        $(“.mhover”).click(function (e) {
            $(this).next(“.mall”).css({“position”:”absolute”,”top”:e.pagey+5,”left”:e.pagex+5}).show();
        });
        $(“.mhover”).mousemove(function (e) {
            $(this).next(“.mall”).css({ “color”: “fff”, “position”: “absolute”, “opacity”: “0.7”, “background-color”: “666”, “top”: e.pagey + 5, “left”: e.pagex + 5 });
        });
        $(“.mhover”).mouseout(function () {
            $(this).next(“.mall”).hide();
        });
    });
</script>

 

3,html内容,在td中新增两个div,两个div中的内容必须一致。

<table>
<tr>
<th>姓名</th>
<th>个性签名</th>
<th>性别</th>
</tr>
<tr>
<td>狗子</td>
<td>
<div class=”mhover”>嘻嘻嘻嘻嘻哈哈12345上山打老虎嘻嘻嘻嘻嘻哈哈</div>
<div class=”mall”>嘻嘻嘻嘻嘻哈哈12345上山打老虎嘻嘻嘻嘻嘻哈哈</div>
</td>
<td>男</td>
</tr>
</table>