Using variable name in click, cant see why not working :-(
Hi
I'm developing a distributor map thing on our company web site, and when a continent is clicked, it sets a variable called 'activeContinent'.
However this works:
- // Outputs 'Africa' in message box
- $('.continent_africa').click(function() {
- alert(activeContinent);
- var currentId = $(this).attr('id');
- });
This doesn't, and I can't see why:
- // Outputs sod all...
- $('.continent_'+activeContinent).click(function() {
- alert(activeContinent);
- var currentId = $(this).attr('id');
- });
I Really cannot see why it won't work. activeContinent is a global variable, and it does have a value, so why won't this work?!
Thanks in advance!
Ste