Reputation: 409
I need to put on the page a few spinners, which are generated by Raphaël. But I can create only one spinner, because Raphaël select elements by id. How I can select many elements for example, by classes? I try use jQuery:
var spinners = $('div.spinners');
var r = Raphael(spinners, 320, 200);
But it doesn't work.
Upvotes: 2
Views: 1014
Reputation: 6944
I have created a small fiddle http://jsfiddle.net/vSZ58/2/
getByClass
, spinner method to paper object.spinner
method creates the element, we are assigning class
attribute to the node of the element.stick.node.setAttribute("class" , classname)
getByClass
method, we are looping all the elements on the
paper and checking whether the passed classname is there in the
element node.if yes its pushed to res
array, which will be the
result.Note:This method works only for the elements created with Raphael. Since you are generating spinners with Raphael it wont be a problem.
If you a declaratively defined some spinners on the svg document,i think its dont possible. If you have any idea on this please update.
Upvotes: 1
Reputation: 414
Try this jQuery each method:
$('div.spinners').each(function(index) {
//alert(index + ': ' + $(this).text());
var r = Raphael(this, 320, 200);;
});
Upvotes: 0