In Raphael docs, we init Raphael with:
var paper = Raphael(document.getElementById("notepad"), 320, 200);
I want to select my class with jQuery and turn it to Raphael, so my thought is:
var paper = Raphael($(".myClass"), 320, 200);
But I get TypeError: b is undefined
in Raphael.js. Does anyone know how to do this?
Try:
var paper = Raphael($(".myClass")[0], 320, 200);
The $
function returns an array-type object of HTML elements, so use [0]
to get the first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With