1

I have a map with Jqvmap plugin, and if we want to select a region by its code, we do:

$('#vmap').vectorMap('set', 'colors', {us: '#ffffff'});
$('#vmap').vectorMap('set', 'colors', {fr: '#ffffff'});

...

But when this code comes from a variable, I do not know how to do:

$('#table td').click(function(){
    var dpt = $(this).text();
    $('#vmap').vectorMap('set', 'colors', {dpt: '#ffffff'});
});
Barak
  • 1,390
  • 15
  • 27
zanzibar
  • 45
  • 1
  • 7

1 Answers1

1

I found a solution :

$('#table td').click(function(){
 var dpt = $(this).text();
 var color = {[dpt]:"#ffffff"};
 $('#vmap').vectorMap('set', 'colors', color);
});
zanzibar
  • 45
  • 1
  • 7