var html = '<table style="width: 100%;border:0.5px solid white; border-spacing:0px; nth-child(even) {color:#ffffff;}"><tr style="background-color:#E9EDDB;padding-top:5px;"><td id="serNum" style="font-family:Segoe UI;font-size:16px;color:#000;text-align:center;width:5%;">' + count + '</td><td style="width: 30%; text-align: left;font-family:Segoe UI;font-size:16px;color:#000;height:auto;overflow-x:none;"><span id="taskDesc" style="">' + i.Description + '</span></td><td style="width: 8%;padding-left:5px; text-align: left;font-family:Segoe UI;font-size:16px;color:#000;"><span id="taskPriority">' + i.Priority + '</span></td><td style="width: 8%; text-align: left;font-family:Segoe UI;font-size:16px;color:#000;"><span id="taskType">' + i.Status + '</span></td><td style="width: 15%; text-align: left;font-family:Segoe UI;font-size:16px;color:#000;"><span id="taskDesc">johnsmith- ' + creatdDate + '</span></td><td style="width: 15%; text-align: left;font-family:Segoe UI;font-size:16px;color:#000;"><span style="display:none" id="taskID">' + i.ID + '</span><select id="dropDown" name="dropDown"><option value="default" SELECTED>Select</option><option value="deleteTask" >DeleteTask</option><option value="createRmndr">CreateReminder</option></select></td></tr></table>';
items.push(html);
count++;
使用這很多列將爲我的項目生成我想改變奇數列的顏色,但我無法改變它可以告訴我如何改變奇數和偶數列的背景顏色。我曾嘗試這個CSS,但這個屬性是不是在JavaScript 工作,所以請告訴我該怎麼做..JavaScript更改css
nth-child(odd)
{
background:#ff0000;
}