David David - 1 month ago 4
Javascript Question

Generating td elements with background color jquery

I am trying to give a color to a generated td element (status of a project) but it's not working , I am getting the data but no color. How do I fix this?

Here's my code :

function(data, status) {
var items = "";
data = $.parseJSON(data);
if (data.toString() !== "") {
$.each(data, function(index, item) {
items += "<tr class='info'>";

if(item.STATUSPROGRESS ==="OK"){
items+='<td bgcolor="#00CC66">';
}
else if(item.STATUSPROGRESS === "NOT OK"){
items+="<td bgcolor='#FF0000'>";
}
else if(item.STATUSPROGRESS === "STATUS REQUIRED"){
items+="<td bgcolor='#FFEC3D'>";
}
else if(item.STATUSPROGRESS === "ACTION REQUIRED FROM COMPANY"){
items+="<td bgcolor='#3DB1FF'>";
}
else if(item.STATUSPROGRESS === "ACTION REQUIRED FROM CUSTOMER"){
items+="<td bgcolor='#FF8B3D'>";
}
else{
items+="<td bgcolor='#FFFFFF'>";
}


items += item.PROJECTID + "</td>";
items += "<td>" + item.DESCRIPTION + "</td>";
items += "<td>" + item.CUSTOMER + "</td>";
items += "<td>" + item.ACCMANAGER + "</td>";
items += "</tr>";

});
}
$("#myTable tbody").append(items);
$("#myTable").trigger("update");



});

Answer

"The bgcolor attribute is not supported in HTML5. Use CSS instead."

style="background-color: #3DB1FF"
Comments