Raphael js如何在每个站点中包含多个图标?用class而不是ID

joe*_*oe8 5 javascript raphael

我怎样才能在一个网站上包含来自Raphaël(http://raphaeljs.com/icons/)的多个图标?

我没有设法通过class ="icon"包含它们,只有id ="icon".因为我在JavaScript中不是很好,所以我在网上搜索但没有找到任何内容.

我在博客上找到的唯一一件事:

    bubble: "M16,5.333c-7.732,0-14,4.701-14,10.5c0,1.982,0.741,3.833,2.016,5.414L2,25.667l5.613-1.441c2.339,1.317,5.237,2.107,8.387,2.107c7.732,0,14-4.701,14-10.5C30,10.034,23.732,5.333,16,5.333z",

a = j[b]("column-1")[f]("h2");
for (var z = a.length; z--;) {
   l = a[z];
   l && g(l[f](i)[0], 32, 32).path(k.bubble).attr(m);
}
Run Code Online (Sandbox Code Playgroud)

.js http://dmitry.baranovskiy.com/site2.js

博客http://dmitry.baranovskiy.com/

因为他在每个帖子前面的跨度中使用"泡沫".

有没有办法用类而不是ID包含它?这是我通过ID包含它的方式

var example = Raphael("example", 50, 60);
example.path("icon-string").attr({fill: "#fff", stroke: "#333"});
Run Code Online (Sandbox Code Playgroud)

然后通过包含它

<span id="example">
Run Code Online (Sandbox Code Playgroud)

met*_*ion 7

您需要将元素放在一个数组中,然后循环它:

var elements = document.querySelectorAll('.paper');
for (i=0; i<elements.length; i++) {
    paper = Raphael(elements[i], 50, 50)
    paper.path(bubble).attr({"fill": "#333"})
}
Run Code Online (Sandbox Code Playgroud)

或jQuery版本使其与IE 6和7兼容

$('.paper').each(function(i){
        paper = Raphael($(this)[0], 50, 50)
        paper.path(bubble).attr({"fill": "#333"})
})
Run Code Online (Sandbox Code Playgroud)

你可以在这里找到一个演示:http: //jsfiddle.net/CHEP9/