本效果调用了jQuery1.3库,表格隔行换色,鼠标放上就变色,用class="stripe"来标识需要使用该效果的表格,除了研究换色外,还可以研究一下用thead定义表头的方法,用jQuery确实能事半功倍。
为解决一些网页特效运行后不能显示效果(例如:jQuery则需要刷新)问题,烈火特别新增网页版演示
网页演示:猛击此处
运行演示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>隔行换色</title> <script src="/uploads/common/js/jquery-1.3.2.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $(".stripe tr").mouseover(function(){ $(this).addClass("over");}).mouseout(function(){ $(this).removeClass("over");}) //移除该行的class $(".stripe tr:even").addClass("alt"); }); </script> <style> th { background:#0066FF; color:#FFFFFF; line-height:20px; height:30px; } td { padding:6px 11px; border-bottom:1px solid #95bce2; vertical-align:top; text-align:center; } td * { padding:6px 11px; } tr.alt td { background:#ecf6fc; /*tr背景色*/ } tr.over td { background:#bcd4ec; /*鼠标高亮行的背景色*/ } </style> </head> <body> <table class="stripe" width="50%" border="0" cellspacing="0" cellpadding="0"> <thead> <tr> <th>姓名</th> <th>年龄</th> <th>QQ</th> <th>Email</th> </tr> </thead> <tbody> <tr> <td>小军</td> <td>23</td> <td>31540205</td> <td>gl.deng@gmail.com</td> </tr> <tr> <td>飞越</td> <td>23</td> <td>31540205</td> <td>gl.deng@gmail.com</td> </tr> <tr> <td>艰险</td> <td>23</td> <td>31540205</td> <td>gl.deng@gmail.com</td> </tr> <tr> <td>同贺</td> <td>23</td> <td>31540205</td> <td>gl.deng@gmail.com</td> </tr> </tbody> </table> </body> </html> <br /><center>如不能显示效果,请按Ctrl+F5刷新本页,更多网页代码:<a href='http://www.veryhuo.com/' target='_blank'>http://www.veryhuo.com/</a></center>提示:可修改后代码再运行!