I have a grid of divs that I want to change when I hover over them. I'm trying to make it so the background color changes to white, and back to grey when the mouse is no longer hovering over them. I've been searching for a while, and I can't seem to find an answer that addresses what I'm looking for.
var d = ("<div class='square'></div>");
var value = [];
function createGrid(numSquares) {
var area = $('#g_area');
var squareSize = Math.floor(area.innerWidth() /numSquares);
var n =0;
for (var i = 0, len = (numSquares*numSquares); i < len; i++) {
area.append(d);
for (var j = 0; j < numSquares; j++) {
$(d).attr('id', n);
n++;
value[n] = 0;
}
}
$('.square').height(squareSize);
$('.square').width(squareSize);
};
function resetGrid() {
$(".square").remove();
}
$(document).ready(function () {
createGrid(32);
});
$('.square').hover(function() {
$(this).css({backgroundColor: '#FFFFFF'}) ;
$(this).css({backgroundColor: '#C8C8C8'}) ;
});