for some reason my "megaPixel" dynamically generated divs aren't responding when I click on them despite writing a function that selects all divs. all the other divs respond when clicked.
function init($input){
  for (i=1; i <= 20; i++){
  $('body').append('<div class="megaPixel" id="megaPixel_' + $input + '"></div>');
  $input = $input + 1;
  }
};
$('div').click(function(){
  $('.megaPixel').css('background-color', 'red');
});
init(1);
 
     
     
     
     
    