1
function myCanvas() {
var c = document.querySelector('#myCanvas');
var ctx = c.getContext('2d');
var img = new Image();
img.src = 'https://www.w3schools.com/html/img_the_scream.jpg';
ctx.drawImage(img, 10, 10);
}
<canvas id="myCanvas" width="650" height="600" style="border:1px solid black;overflow: scroll;"></canvas>
<br>
<button onclick="myCanvas()">Click</button>
In the code snippet above I need to double-click to create an image within the element <canvas>
why is this happening? I want the first click to create an image.