jQuery實現表格顏色交替顯示的方法
來源:易賢網 閱讀:1177 次 日期:2015-03-11 15:12:53
溫馨提示:易賢網小編為您整理了“jQuery實現表格顏色交替顯示的方法”,方便廣大網友查閱!

這篇文章主要介紹了jQuery實現表格顏色交替顯示的方法,涉及jQuery操作表格樣式的技巧,非常具有實用價值,需要的朋友可以參考下

本文實例講述了jQuery實現表格顏色交替顯示的方法。分享給大家供大家參考。具體實現方法如下:

代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">

<head>

<title>jQuery實現表格顏色的交替顯示</title>

<script type="text/javascript" src="js/jquery1.3.2.js"></script>

<script type="text/javascript">

jQuery(document).ready(function(){

jQuery(".truecolor tr:odd").addClass("color1");

jQuery(".truecolor tr:even").addClass("color2");

jQuery(".truecolor tr").hover(function(){

jQuery(this).addClass("color3")

},function(){

jQuery(this).removeClass("color3")

});

});

</script>

<style type="text/css">

.truecolor {border:1px solid #333;text-align:center;}

.truecolor th {background-color:#333; color:#FFF;}

.color1 {background-color:#DDD; color:#333;}

.color2 {background-color:#EEE; color:#333;}

.color3 {background-color:#666; color:#FFF;}

</style>

</head>

<body>

<table width="450" class="truecolor">

<thead>

<tr>

<th>博客</th>

<th>作者</th>

<th>網址</th>

</tr>

</thead>

<tbody>

<tr>

<td>風格之舞</td>

<td>火德</td>

<td>隔行換色</td>

</tr>

<tr>

<td>趙雷的博客</td>

<td>趙雷</td>

<td>新浪微博</td>

</tr>

<tr>

<td>寂寞廣場</td>

<td>魏春亮</td>

<td>同學錄</td>

</tr>

<tr>

<td>淘寶UED</td>

<td>淘寶</td>

<td>經常購物</td>

</tr>

</tbody>

</table>

</body>

</html>

希望本文所述對大家的jQuery程序設計有所幫助。

更多信息請查看IT技術專欄

更多信息請查看腳本欄目
易賢網手機網站地址:jQuery實現表格顏色交替顯示的方法
由于各方面情況的不斷調整與變化,易賢網提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢為準!

2026國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
云南網警備案專用圖標
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網
云南網警報警專用圖標
未满十八18勿进黄网站免费看