Having issues with variable and click

Having issues with variable and click

Hi

I am working on a world map thing for work, and basically this little bit of code just won't work, but if I replace the variable with text it does.

This works:
  1. //outputs 'africa'
  2. $('.continent_africa').click(function() {
  3. var flagId = $(this).attr('id');
  4. alert(flagId);
  5. });
However this doesn't, and I really can't see why because the variable is set and is global
  1. //does not blumin work!
  2. var continentClass = '.continent_africa';
  3. $(continentClass).click(function() {
  4.       var flagId - $(this).attr('id');
  5.       alert(flagId);
  6. });
In practice the continentClass is set elsewhere I just put it like this for testing purpose. ANY ideas because I am getting really frustrated now.