Lite Brite won't light up


#1

I am having the same issue, I cannot find the error in my code which is below:

function main() {
 
  var colorClass = '';
  
  $('.select-color').on('click', function() { //this is the click function
    var selectedColor = $(this).attr('class'); //this saves the selected color
   
    switch(selectedColor) {
      case 'select-color cyan not-selected':
        colorClass = 'cyan';
      break;
      case 'select-color yellow not-selected':
        colorClass = 'yellow';
      break;
      case 'select-color magenta not-selected':
        colorClass = 'magenta';
      break;
    }
  $(this).removeClass('not-selected'); // this makes the buttons light up once selected
    $(this).siblings().addClass('not-selected');    // this make sure all selected colors won't stay lit
  });
  
  $('.box').on('click', function() {  // this is click function for boxes 
    $(this).toggleClass(colorClass);  // selects the box clicked and picks a color
  });
  
}
$(document).ready(main); //calls back function main

Lite Brite Project Won't Light Up