javascript - Uncaught TypeError: Cannot read property 'getContext' of null Help Please -


i keep getting error in title. doing wrong? dont want use jquery. know there simple answer this, im literally not seeing it.

<!doctype html> <html> <body> <canvas id="canvas1" width="500px" height="500px"> </canvas>  <script>     var canvas = document.getelementbyid("#canvas1");     var c = canvas.getcontext("2d");      c.beginpath();     c.moveto(0,0);     c.lineto(100,100);     c.stroke(); </script> </body> </html> 

you done minor mistake @ following line

 var canvas = document.getelementbyid("#canvas1"); 

instaed specify id without # like

  var canvas = document.getelementbyid("canvas1"); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -