我想使用下面的代碼來交替我的表的行和列。替代表行和列顏色與jQuery
<script>
$(document).ready(function()
{
$("table#id2 td:even").css("background-color", "LightGray");
$("table#id2 tr:even").css("background-color", "LightBlue");
$("table#id2 tr:odd").css("background-color", "LightYellow");
});
</script>
當我用這個,我的2列的表看起來是這樣的:
Gray Blue
Gray Yellow
Gray Blue
Gray Yellow
我想我的表看起來像這樣:
Gray Blue
Yellow Yellow
Gray Blue
Yellow Yellow
這可能使用td:even,tr:odd等。?
爲什麼jQuery?爲什麼不簡單的CSS? – rahularyansharma
看看這個鏈接http://devtechie.com/post/2011/09/30/Format-GridView-table-rows-using-jQuery.aspx – Santosh