What not are 3 square? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

What not are 3 square?

<canvas id="canvas 1" width=200 height=200></canvas><script> var c=document.getElementById ("canvas 1"); var ctx=c .getContext("2d"); ctx.fillRect (20,20,100,100,)</script> <canvas id="canvas1" width="200" height="200"> </canvas> <script> var c=document.getElementById("canvas1"); var ctx=c.getContext("2d"); ctx.fillRect(20,20,100,100); </script> <canvas id="canvas1" width="200" height="200"> </canvas> <script> var c=document.getElementById("canvas1"); var ctx=c.getContext("2d"); ctx.fillRect(20,20,100,100); </script>

17th Jan 2020, 3:10 PM
🇷🇴Golden Fish🇷🇴
1 ответ
+ 3
because you use twice the id value of "canvas1" (the first id "canvas 1" is different) and so, when you try to access the third canvas you target the first element with id "canvas1" wich is the second canvas where you already have fill a square ^^
17th Jan 2020, 4:40 PM
visph
visph - avatar