jquery - RaphaelJS + jQuery : How to define ID and CLASSES for paths

标签 jquery svg

嗯,我的问题很简单。

我正在使用 RaphaelJS 制作具有悬停效果的国家 map ,但如何通过悬停获取州 ID?

假设您有这个示例路径。

var path = paper.path('coordinates_here');

如何使用 jQuery 识别此路径? 示例:

    $('#myPathId').mouseenter(function(){
       //do something here
    });

最佳答案

您可以使用 Raphaeljs 的内置事件绑定(bind)像:

path.mouseover(function (event) {
    //do something
});

或者如果你真的想使用 jQuery 来进行事件绑定(bind),你可以这样做:

$(path.node).mouseenter(function(){
       //do something here
    });

假设

var path = paper.path('coordinates_here');

关于jquery - RaphaelJS + jQuery : How to define ID and CLASSES for paths,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7236031/

相关文章:

javascript - 在特定视口(viewport)宽度处禁用 Owl Carousel

jquery - 悬停时的 Swing 元素动画

javascript - 实现与模态框关联的作业删除按钮

javascript - 是否可以反转 SVG 的裁剪?

javascript - select2 无法在带有母版页的 aspx 页面中工作

javascript - 动态插入的 JQuery Mobile slider

javascript - 将 SVG 数据转换为可上传的 SVG 文件

javascript - 悬停 div svg 路径颜色更改

javascript - svg defs def 在 d3 中的可变位置

javascript - d3 从 svg 中删除文本