我的所有画布绘图函数都是这样开始的:
function drawMe(){
var canvas = document.getElementById('canvas-id');
var ctx = null;
ctx = canvas.getContext('2d');
...
}
然而,我现在想在(变量数量的)多个画布上绘制相同的图像,有没有一些替代方法可以代替getElementById()
(也许是在jQuery中?),可以轻松地一次性获取多个元素?
谢谢!
乔希