Answer the question
In order to leave comments, you need to log in
Why doesn't canvas clone work?
I'm trying to clone the created canvas, something doesn't work
<div class="small-container">
<canvas id="myCanvas"></canvas>
</div>
<div id="target">
</div>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var imageObj = new Image();
imageObj.onload = function() {
context.drawImage(imageObj, 0, 0, 300, 300);
};
imageObj.src = 'https://www.photographyatthesummit.com/wp-content/uploads/2013/03/p-nature43-300x300.jpg';
var clone = canvas.clone();
var target = $("#target")
clone[0].getContext('2d').drawImage(canvas[0],0,0, 300, 300);
target.html(clone);
Answer the question
In order to leave comments, you need to log in
What's wrong ?
$(canvas).clone()
. canvas = document.getElementById('myCanvas');
<...>
drawImage(canvas[0],
canvas = $('#myCanvas')
drawImage(canvas,
Have you tried looking at the console?
canvas.clone is undefined
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question