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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -