In this post, we will see how to resolve HTML Canvas Eraser and Pen not working as intended
Question:
I have a canvas that has a pen and eraser button. Unfortunately, clicking either of the buttons does nothing. I want the eraser to change into the color white and the pen to be black. I cannot figure out what is causing my code to not work. Here is my javascript code.Best Answer:
I am not a canvas guy, but looking into the code, found thatctx.strokeStyle = $('#selColor').val();
this is causing issue. Commenting this line worked for me.If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com