有没有人知道是否可以通过类名而不是id来设置拉斐尔容器?
例如,这是可行的:
Raphael("holder", 100, 100));这是可行的:
var container = document.getElementById('holder');
Raphael(container, 100, 100));但这不起作用:
var container = $('#holder');
Raphael(container, 100, 100));但这并不起作用:
var container = document.getElementsByClassName('holder');
Raphael(container, 100, 100));这肯定行不通:
Raphael($('.holder:last'), 100, 100));除了这种情况之外,拉斐尔在我的代码的其他所有部分都很好地使用了jQuery。我需要完成一些类似上一个示例的事情。想法?
发布于 2012-08-18 03:31:30
//i've tried this one and it works with [0] to select first of array
var container = $('#holder');
Raphael(container[0], 100, 100));
//so i think theses should work too
var container = document.getElementsByClassName('holder');
Raphael(container[0], 100, 100));
Raphael($('.holder:last')[0], 100, 100));https://stackoverflow.com/questions/12011940
复制相似问题