I am trying to implement a for loop into my Javascript/jQuery code, which I know works since I did the testing before I implemented the for loop. I found the for loop syntax off of this website: http://www.w3schools.com/js/js_loop_for.asp I am not sure how to implement my variable "i" into my for loop within the .css jQuery method. What am I doing wrong? Here is my code:
for(var i=0;i<36;i++) {
$(".quote_" + i).mouseenter(function(){
$("td.quote_" + i).css("background-color", "rgb(238, 238, 238)");
});
$(".quote_" + i).mouseleave(function(){
$("td.quote_" + i).css("background-color", "white");
});
}
This is the code which I know works:
$(".quote_1").mouseenter(function(){
$("td.quote1").css("background-color", "rgb(238, 238, 238)");
});
$(".quote_1").mouseleave(function(){
$("td.quote_1").css("background-color", "white");
});