方法一:
#customers tr:hover { background-color: #f00; }
方法二:
<tr onmouseover="style.backgroundColor='#FF9900'" onmouseout="style.backgroundColor='#FFFFFF'"> <td>Apple</td> <td>Steven Jobs</td> <td>USA</td> </tr>
完整样例:
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 <html> 2 <head> 3 <style type="text/css"> 4 #customers 5 { 6 font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; 7 width:100%; 8 border-collapse:collapse; 9 } 10 11 #customers td, #customers th 12 { 13 font-size:1em; 14 border:1px solid #98bf21; 15 padding:3px 7px 2px 7px; 16 } 17 18 #customers th 19 { 20 font-size:1.1em; 21 text-align:left; 22 padding-top:5px; 23 padding-bottom:4px; 24 background-color:#A7C942; 25 color:#ffffff; 26 } 27 #customers tr:hover 28 { /*方法一*/ 29 background-color: #f00; 30 } 31 </style> 32 </head> 33 34 <body> 35 <table id="customers"> 36 <tr> 37 <th>Company</th> 38 <th>Contact</th> 39 <th>Country</th> 40