+3

What did I do wrong?

I am trying to learn Html's canvas but I somehow did something wrong in even resizing the canvas! Can anyone show me what I did wrong? https://code.sololearn.com/WJIzI9yy4SM8/?ref=app

8/14/2018 1:53:37 PM

S. C.

4 Answers

New Answer

+2

1. getElementsByTagName return an array. Access the 1st element by using canvas[0] or just use Id directly. 2. The canvas may not be created yet, wrap the code in window.onload. 3. Meet Mehta Please don't encourage the use of resizing canvas through CSS. It also scales the bitmaps inside. https://code.sololearn.com/W8LJGkUCUvZS/?ref=app

+3

see this: https://youtu.be/EO6OkltgudE go to 6:33

+2

Meet Mehta appreciate your help but I am trying to use JS for resizing it.

+2

you are just editing css with js. i want to directly edit the size of the canvas with js.