+ 4

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

14th Aug 2018, 1:53 PM
Satyam
4 Answers
+ 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
14th Aug 2018, 2:29 PM
HoĂ ng Nguyễn Văn
HoĂ ng Nguyễn Văn - avatar
+ 4
see this: https://youtu.be/EO6OkltgudE go to 6:33
14th Aug 2018, 2:27 PM
Satyam
+ 3
Meet Mehta appreciate your help but I am trying to use JS for resizing it.
14th Aug 2018, 2:17 PM
Satyam
+ 3
you are just editing css with js. i want to directly edit the size of the canvas with js.
14th Aug 2018, 2:20 PM
Satyam