You'll need to use .each()
to iterate over all elements with that class.
$('.myCanvas').each(function() {
var canvas = $(this)[0];
var context = canvas.getContext('2d');
// Do stuff
});
Working JSFiddle.
That is because you are using class in jquery.
Change this
var context = $('.dropzone').getContext('2d');
to
var context = $('#dropzone').getContext('2d');
Use .each()
$('.dropzone').each(function(index, element) {
var context = element.getContext('2d');
context.beginPath();
context.moveTo(0, 200);
context.lineTo(578, 0);
context.stroke();
context.beginPath();
context.moveTo(0, 0);
context.lineTo(578, 200);
context.stroke();
});
Here's an example on jsfiddle.