如何将代码添加到以下以交替行颜色
parsedata = function(xml){
var str = "";
var cart = xml.documentElement.firstChild;
if(cart.childNodes.length > 0 ){
str = str + '<table border="0" width="100%" cellspacing="0" cellpadding="5">';
str = str + ' <tr><td class="animBoxCartLink" colspan="2"><a href="' + globals.cart_link + '">' + globals.cart_text + '</a></td></tr>
for (var i = 0; i < cart.childNodes.length; i++){
try{name = cart.getElementsByTagName("NAME")[i].childNodes[0].nodeValue;}catch(e){name = "Item";}
try{attributes = cart.getElementsByTagName("ATTRIBUTES")[i].childNodes[0].nodeValue;}catch(e){attributes = "";}
try{llink = cart.getElementsByTagName("LINK")[i].childNodes[0].nodeValue;}catch(e){llink = "";}
try{image = cart.getElementsByTagName("IMAGE")[i].childNodes[0].nodeValue;}catch(e){image = "No Image";}
try{qty = cart.getElementsByTagName("QTY")[i].childNodes[0].nodeValue;}catch(e){qty = "message";}
try{price = cart.getElementsByTagName("PRICE")[i].childNodes[0].nodeValue;}catch(e){price = "$0.00";}
dimension = (globals.cart_image_width ? 'width="' + globals.cart_image_width : '') + (globals.cart_image_height ? '" height="' + globals.cart_image_height + '"' : '');
str = str + ' <tr>';
str = str + ' <td class="animBoxCartImage" width="' + globals.cart_image_width + '" align="center"><a href="' + llink +'"><img src="' + image + '" ' + dimension + ' border="0" alt="' + name + '"></a></td>';
str = str + ' <td class="animBoxCartContent" width="100%">';
str = str + ' <div class="animBoxCartName"><a href="' + llink + '">' + name + '</a><br />' + attributes + '</div>';
str = str + ' ' + globals.text_cart_quantity + ' ' + qty;
str = str + ' <div class="animBoxCartPrice">' + price + '</a></div>';
str = str + ' <a href="' + llink + '"> More Info </a>';
str = str + ' </td>';
str = str + ' </tr>';
.js 文件(Jquery)的前半部分主要与位于标题中的购物车的显示/隐藏有关,而我刚刚发布的部分是我认为需要在可以添加代码的地方添加样式,以便行颜色交替。