Basically I'm trying to change background-color of some JQuery added divs of class="cell" into a parent div of class="grid". So the "cell" class isn't defined in the original index.html
so it works when i write the code like this:
$(document).ready(function() {
var clr = "red";
$('.cell').mouseenter(function() {
$(this).css('background-color', clr);
});
});
but it doesn't when i define a function like:
$(document).ready(function() {
function fillCell(clr){
$(this).css('background-color', clr);
}
$('.cell').mouseenter(function() {
alert(clr); //added for test
fillCell("red");
});
});
please note that the alert() is triggered when hovering and responds with "red".