Re: [問題] 表格隔行背景色

看板Web_Design作者 (我是沒牌的營養師!)時間17年前 (2008/04/30 09:57), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串4/4 (看更多)
※ 引述《adamp3 (Boston's 10th Man.)》之銘言: : 請問除了用<td class = "even">text</td>以外 : 有沒有辦法用javascript去跑 : 讓表格每隔一行的顏色會不同 : 如下 : col col2 : row1 text text : row2 text text : row3 text text : row4 text text : 請高手解答! : 最近弄表格弄到快瘋了 囧 要不要試試jQuery :) 先定義style : <style> .oddTr{ background-color:#999999; } </style> 再加個jQuery的ready事件 : <script language="javascript"> $().ready(function(){ $('tr:odd').addClass('oddTr'); //在奇數列掛上.oddTr這個style }); </script> 底下table隨便做 : <table border="1" width="300"> <tr> <td>1111</td> </tr> <tr> <td>2222</td> </tr> <tr> <td>3333</td> </tr> <tr> <td>4444</td> </tr> </table> 收工,希望有幫上忙 :) -- http://blog.eddie.com.tw/ http://www.eddie.com.tw/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.132.128.37

04/30 09:58, , 1F
喔,別忘了去下載jquery的js回來include進去 :)
04/30 09:58, 1F
文章代碼(AID): #185z7skl (Web_Design)
文章代碼(AID): #185z7skl (Web_Design)