jqueryの奇数/偶数セレクターを使用して、テーブルに「タイガーストライピング」を作成しています。次に、行を追加または削除する機能を追加しました。ただし、行の追加/削除時にストライピングを適切に機能させることができませんでした。追加/追加では機能しますが、追加/先頭または削除では機能しません。ここにコードの要約があります...
$(document).ready(function(){
// click on Add Row button
$("#addButton").click(function(){
// add a row to table
addTableRow('#myTable');
// then re-apply tiger striping
stripeRows();
});
});
// remove specified row
function removeRow(row) {
$(row).parent("tr").remove();
stripeRows();
}
function StripeRows()
{
$("#myTable").each(function(){
$(this).find("tr:even").addClass("evenrow");
$(this).find("tr:odd").addClass("oddrow");
});
}