状態の配列をセットアップしようとしていますが、配列に状態または値が存在する場合は関数を実行します。以下は、私が変更しようとしている実際のコードであり、「stateRedirects」変数は、if (code === stateRedirects ) { }...
var stateRedirects = [
'US-TX',
'US-CA',
'US-AL'
// more will be added
]
$('.map').vectorMap({
map: 'us_en',
backgroundColor: 'transparent',
color: '#0071A4',
hoverColor: false,
hoverOpacity: 0.5,
normalizeFunction: 'polynominal',
scaleColors: ['#C8EEFF', '#0071A4'],
onLabelShow: function(event, label, code){
if (code === stateRedirects ) {
//do nothing
}
else if (code) { //if a state is not specified in var stateRedirects then prevent default
event.preventDefault();
}
},
onRegionOver: function(event, code){
if (code === stateRedirects ) {
//do nothing
}
else if (code) { //if a state is not specified in var stateRedirects then prevent default
event.preventDefault();
}
},
onRegionClick: function (event, code) {
window.location = '/' + code;
}
});
コメントごとに [ と ] を使用するように変更しましたが、コードがこの行の配列と一致するかどうかを確認する方法がわかりませんif (code === stateRedirects ) {