Changing background-color from separately elements from an array (jquery) -


this code:

$(document).ready(function() {           for( var = 0 ; < 8 ; i++ ){         for( var j = 0 ; j < 8 ; j++ ){             var $class = getpiecename(board[i][j][0])             $(.$class ????).click(function() {                 $(this).css('background-color', 'red');                  });         }     }            }); 

as can see, want change background color of element. for-loops needed element, in array, wich user clicked on. how write variable ($class) class?

if class string can use this:

$("." + $class).click(function(){ ... }); 

Comments