+ 1
Canvas
When ever I write this statement var c = canvas.get context("2d"); it gives me error why is there any mistake or compiler problem I have seen many programs in which it gives error "get context of null"
4 Antworten
+ 4
Write your js code in
onload=()=>{
//Write your code
}
+ 4
If you're getting "cannot access property getContext of null" or something like that then most probably, your program is not able to select the canvas element. Make sure that your code is inside the window.onload function and that you are selecting the canvas element in the correct way. No one can say much till you post your full code.
+ 1
Maybe you made a typo! Don't worry, I do a lot lol 🤣🤣🤣
I just Googled it, and it's supposed to be canvas.getContext("2d"); without space and the C is capital!
Hope it works! :)