I have a button to clear the drawings of my canvas element as follows:
<button id="button_clear" onclick="clear()" > Clear ! </button>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid #d3d3d3;">
Clear function is like that :
function clear(){
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.clearRect(0, 0, c.width, c.height);
ctx.beginPath();
}
However when I click on the clear button, my function does not do anything at all.