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:
- //outputs 'africa'
- $('.continent_africa').click(function() {
- var flagId = $(this).attr('id');
- alert(flagId);
- });
However this doesn't, and I really can't see why because the variable is set and is global
- //does not blumin work!
- var continentClass = '.continent_africa';
- $(continentClass).click(function() {
- var flagId - $(this).attr('id');
- alert(flagId);
- });
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.