table td text is longer than the length of the content beyond the ellipsis hidden, you click on Show All Content

1. Set css styles

<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 settings and click mousemove and mouseout events

<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 content, add two div in the td, the contents of the two div must be consistent.

<the Table>
<TR>
<TH> Name </ TH>
<TH> Signature </ TH>
<TH> gender </ TH>
</ TR>
<TR>
<td> Gouzi </ td>
<td>
<div class = "MHover"> hehehe laughing 12345 uphill tigers hehehe laughing </ div>
<div class = "MALL"> hehehe laughing 12345 uphill tigers hehehe laughing </ div>
</ TD>
<TD> M </ TD>
</ TR>
</ Table>

Guess you like

Origin www.cnblogs.com/cqj98k/p/11468736.html