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 中不起作用所以请告诉我如何做到这一点..
nth-child(odd)
{
background:#ff0000;
}