0
在家教「與SVG和jQuery動態地理地圖」,我想用<br>
添加的信息框的詳細信息,但是地圖則信息框消失。請看下面的例子。添加的信息框更多信息,與SVG和jQuery
http://codepen.io/SitePoint/pen/KDHfh
$(function() {
for(i = 0; i < regions.length; i++) {
$('#'+ regions[i].region_code)
.css({'fill': 'rgba(11, 104, 170,' + regions[i].population/highest_value +')'})
.data('region', regions[i]);
}
$('.map g').mouseover(function (e) {
var region_data=$(this).data('region');
$('<div class="info_panel">'+
region_data.region_name + '<br>' +
'Test: ' + region_data.test + '<br>' +
'Population: ' + region_data.population.toLocaleString("en-UK") +
'</div>'
)
.appendTo('body');
})
.mouseleave(function() {
$('.info_panel').remove();
})
.mousemove(function(e) {
var mouseX = e.pageX, //X coordinates of mouse
mouseY = e.pageY; //Y coordinates of mouse
$('.info_panel').css({
top: mouseY-50,
left: mouseX - ($('.info_panel').width()/2)
});
});
});
哇。這行得通。非常感謝你,SAURABH夏爾馬 – user2208982
@ user2208982請標出答案接受,如果它已經解決了您的問題 –
我只是做了。謝謝 – user2208982