我试图改变地图的颜色,如果低于35,它会通过并获得阿拉斯加但在此之后停止。是不是应该循环并为每个低于35的颜色分配颜色?我不知道为什么这不起作用。
$(document).ready(function() {
$.each(states, function(i, stateData) {
losingState = stateData.Abb;
currentState = this;
if (currentState.wins < 35) {
var testState = currentState.Abb;
var fillColor = "red";
$('#map').brett({
stateSpecificStyles: {
[testState]: {
fill: fillColor
},
},
'mouseoverState': {
'HI': function(event, data) {
//return false;
}
},
'click': function(event, data) {
$('#alert')
.text('Click ' + data.name + ' on map 1')
.stop()
.css('backgroundColor', '#ff0')
.animate({
backgroundColor: '#ddd'
}, 1000)
.append('<p><strong>' + currentState.name + '</strong> has a winning percentage of <span class="percentage">' + currentState.wins + '%</span></p>');
}
});
} else {
var fillColor = "green";
var winningState = currentState.Abb;
}
});
});