我正在尝试开发交互式 SVG 地图,当鼠标进入 SVG 图像中的矩形时,我想做一些事情。目前,当我的鼠标进入 SVG 图像时,代码会记录到控制台,但当我将鼠标悬停在矩形上时不会。任何帮助将非常感激。谢谢!
<object onload="svgOnLoad()" id="activeSVG" data="SVGNAME.svg" type="image/svg+xml">
</object>
<script>
function svgOnLoad() {
console.log("SVG Loaded");
$("#activeSVG").mouseenter(function(e) {
console.log("In the SVG")
});
//Executed when the mouse enters an SVG rect element
$("rect").mouseenter(function(e) {
console.log("Mouse Entered rectangles!!")
});
}
</script>