How do I change the background color of a div with id='1' and class='std' to red using jQuery (assuming i equals 1)?
$("#" + i).css("background-color", "red");
Here is the code snippet:
for(var i=0 ; i< info.length ; i++ ){
var div_std ='<div id="'+i+'" class="std"> <p> Name :<b> '+info[i].nom_etud + ' </b></p> <hr><p> Abs Hours : '+info[i].hr_cours +'</p>' ;
div_std+='<p> TPs Hours : '+info[i].hr_tp+'</p><section id="footstd"><button type="button" name="">Mark as absent</button><img src="images/abs.png"></section>'+'</div>';
if(info[i].col == 1)
{
$(function() {
$("#\\" + i.toString().charCodeAt(0).toString(16)).css("background", "red");
});
}
else if(info[i].col == 2)
$(function() {
$("#\\" + i.toString().charCodeAt(0).toString(16)).css("background", "blue");
});
else if(info[i].col == 3)
$(function() {
$("#\\" + i.toString().charCodeAt(0).toString(16)).css("background", "green");
});
$(".main").append(div_std); //Display the students name
}