如果用户点击任何一个状态,则点击SVG India Map,然后该区域应该作为背景颜色“绿色”激活,如果用户点击任何其他状态,则应取消选择前一个状态,并且应使用bg激活新的点击状态颜色“绿色”。
表示用户只能选择1个状态,如果用户点击其他状态,则应取消选择其他状态。
希望我的问题很明确。
这是我的工作网址: http://www.acmearchitectural.com/indiamapsvgfiles/map.html
此致
答案 0 :(得分:1)
$(document).ready(function(e) {
$('path[id^="map_"]').click(function(){
$('#regions path').css('fill','');
$(this).css('fill', "green");
});
});
答案 1 :(得分:0)
只需使用
$('path[id^="map_"]').click(function(){
$('path[id^="map_"]').removeAttr('style');$(this).css('fill', "green");
});
答案 2 :(得分:0)
只需在你的html文件中替换$(document).ready函数。
$(document).ready(function(e) {
$('path[id^="map_"]').click(function(){
$('path[id^="map_"]').css('fill', "rgb(235, 236, 237)");
$(this).css('fill', "green");
});
});