Я использую JQVMap, и у меня есть код, в зависимости от того, в каком состоянии вы нажмете, он откроет информацию об этом состоянии в пределах одного div под картой. Тем не менее, я считаю, что есть упрощенный, более эффективный способ настроить этот код, поэтому повторения не так много, особенно после того, как я начну добавлять больше состояний. Здесь?Упростить jQuery Switch Case
switch(code){
case"tx":
$('#info-children').children(':not(#info-tx)').hide("slow");
$('#info-children').children('#info-tx').show("slow");
break;
case"il":
$('#info-children').children(':not(#info-il)').hide("slow");
$('#info-children').children('#info-il').show("slow");
break;
case"fl":
$('#info-children').children(':not(#info-fl)').hide("slow");
$('#info-children').children('#info-fl').show("slow");
break;
case"ga":
$('#info-children').children(':not(#info-ga)').hide("slow");
$('#info-children').children('#info-ga').show("slow");
break;
case"pa":
$('#info-children').children(':not(#info-pa)').hide("slow");
$('#info-children').children('#info-pa').show("slow");
break;
default:
$('#state-name').html(region);
$('#info-children').children(':not(#info-uhoh)').hide("slow");
$('#info-children').children('#info-uhoh').show("slow");
}
Огонь! Виноват. –