Css+js Mouse hover cell color

Source: Internet
Author: User

    • Another mouse hover table cell, table color instance effect, the use of CSS and JS technology combination, because of some compatibility is very good, and easy to control, code modification is convenient, with the table read Dynamic Data does not have any relationship, more convenient.

<title> mouse hover cell color </title>
<meta http-equiv= "Content-type" content= "text/html;charset=gb2312" >
<style type= "Text/css" >
<!--
#myTable {
Width:100%;border-collapse:collapse;margin:1em 0;
}
#myTable th,td{
text-align:left;padding:.5em;border:1px solid #fff;
}
th{
Background-color: #328aa4; color: #fff;
}
Td{background: #e5f1f4;}
Tr.even td{background: #e5f1f4;}
Tr.odd td{background: #f8fbfc;}
Tr.over td{background: #bce774;}
Tr.out td{}
-
</style>
<body onload= "CHANGETABLEBG (); >
<table width= "id=" myTable "cellspacing=" 0 "cellpadding=" 0 ">
<tr>
<th>title</th>
<th>title</th>
<th>title</th>
</tr>
<tr>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
<tr>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
</table>
<script type= "Text/javascript" >
<!--
function Changetablebg ()
{
var Changetr=document.getelementbyid ("MyTable"). getElementsByTagName ("tr");
for (i=0;i<changetr.length;i++)
{
Changetr[i].classname= (i%2>0)? " Even ":" Odd ";
Changetr[i].temp=changetr[i].classname;
Changetr[i].onmouseover=function () {
This.classname= ' over ';
}
Changetr[i].onmouseout=function () {
This.classname=this.temp;
}
}
}
-
</script>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.