[solved]Please teach me why property "width" is null? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

[solved]Please teach me why property "width" is null?

I'm beginner of programming (and English). I don't know why I could get canvas' width. https://code.sololearn.com/Wct92EwbeVWJ/?ref=app

24th Feb 2021, 1:38 PM
bill peteson
bill peteson - avatar
4 Answers
+ 4
probably it is treating ”test” as a whole string including those ”” characters as well . So you need to select id this way , document.getElementById("”test”" Or you could just use right characters (i.e. "test") if you want only test to be interpreted as string.
24th Feb 2021, 1:48 PM
Abhay
Abhay - avatar
+ 3
The value for id attribute of the <canvas> is wrapped with slanted quotation marks. This in turn, makes the browser ignores the attribute and its value.
24th Feb 2021, 2:19 PM
Ipang
+ 2
// your incorrect code id=”test” // correct code id="test" different symbol ” & " https://code.sololearn.com/WEOdYenUT4HB/?ref=app
24th Feb 2021, 3:32 PM
SAN
SAN - avatar
+ 1
Thank you for every answers. I could get property width by erase quotation marks of id="test".
24th Feb 2021, 8:51 PM
bill peteson
bill peteson - avatar