其次,我使用raphaeljs lib在不同的路径中进行SVG表单转换
我希望通过raphaeljs 2.1.0 =>的功能调用他来获得一条路径。 getById(ID);
但Chrome或Firefox告诉我没有函数getById!我不明白为什么?
这是我的一段代码:
rsrGroups = [path_c_trsp,path_i_trsp,path_l_trsp,path_o_trsp];
len = rsrGroups.length;
for(var i = 0; i < len; i++){
var el = rsrGroups[i];
el.mouseover(function() {
rsrGroupsMin.forEach(function(el){
var getPath = el.getById('el.id'); // here is the method called !
alert(getPath);
el.animate({opacity: 0.5},350,function () {});
rsrGroups2.forEach(function(tri){
tri.animate({opacity: 0.5},350,function () {});
});
});
this.animate({opacity: 1},350,function () {});
});
}
这是Chrome给出的错误:
Uncaught TypeError:ObjectRaphaël的对象没有方法'getById'
我尝试了不同的东西,但没有人工作:/
答案 0 :(得分:2)
getById是纸质对象上的一种方法,而不是元素,即
var paper = Raphael(10, 50, 320, 200);
paper.getById('id')
或者如果您无法访问纸质变量,可以调用el.paper.getById
答案 1 :(得分:-1)
您的意思是el.getElementById('el.id')
吗?