我刚刚开始研究Raphael,每个教程都说你可以通过这样做来吸取元素:
element = Raphael(elementId);
现在说我有一堆<div>
所有class='icon'
并且我希望使用Raphael在这个div的所有出现中绘制相同的图像。我该怎么做?
答案 0 :(得分:1)
你可以做的是设置一个'each'功能并循环遍历所有图标并在每个图标上绘制。像这样,
var papers = []
$(".icon").each(function(index, element){
papers.push(Raphael(element, "100%", "100%"));
papers[index].rect(x,y,height,width); //replace this with the code you will use to draw your icon.
});
这应该有效,但如果您有任何问题请发表评论。