我在 Raphael JS 中遗漏了一些明显的东西。我 a) 循环遍历数组,b) 从值中绘制圆圈,c) 创建文本叠加,d) 在 Raphael 中设置监听器。
我所困扰的是听众的行动。具体来说,如何通过 id 获取元素,然后执行诸如将其移动到顶部之类的操作。
来源 JSFiddle http://jsfiddle.net/NPks2/3/
我希望这能起作用,但事实并非如此。你能帮忙吗?
// this happening while looping through an object
var p = paper.circle(x_coord, y_coord, diameter)
.data("i", i)
.attr({"fill": "90-"+fillColorStart+":5-"+fillColorEnd+":95","fill-opacity": 0.5})
.glow({color: "#4b4b4b", width: 7})
paper.text(x_coord, y_coord, opportunityTitle)
.data("text_id", i+"text")
.attr({ "font-size": 16, "font-family": fontFamily, "fill":fontColor});
paper.text(x_coord, title_y_coord, ideasCount)
.attr({ "font-size": 27, "font-family": fontFamily, "fill":fontColor});
// loop is over, listeners are waiting
paper.forEach(function(element) {
element.mouseover(function() {
c = elem_id = this.data("i");
t = p.getById(elem_id"+text);
c.toFront();
t.toFront();
});
});
最佳答案
关于javascript - Raphael JS - 通过 id 获取元素,将该元素移动到顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10590598/