+ 1

Its giving error..saying context is not defined..any clue friends.??

var canvas=$("#canvs"); var context=canvas.get(0).getContext("2d"); context.fillRectangle(40,30,100,120);

11th Mar 2017, 1:56 PM
suraj pandey
suraj pandey - avatar
7 odpowiedzi
+ 1
@jose but it still have same issue
11th Mar 2017, 2:04 PM
suraj pandey
suraj pandey - avatar
+ 1
@jose hey not working..same error
11th Mar 2017, 2:16 PM
suraj pandey
suraj pandey - avatar
+ 1
I have copied and pasted in q&a from playground..lhave tried it lot but can't understand what's wrong.included needed SRC in HTML for both js and jquery ...
11th Mar 2017, 2:31 PM
suraj pandey
suraj pandey - avatar
+ 1
error now showing. can not read property getContext of null???
11th Mar 2017, 5:54 PM
suraj pandey
suraj pandey - avatar
0
don't use the # for the id up there
11th Mar 2017, 2:00 PM
Welliton Malta
Welliton Malta - avatar
0
try this way var context = $("#canvs")[0].getContext('2d');
11th Mar 2017, 2:07 PM
Welliton Malta
Welliton Malta - avatar
0
maybe it's another typing error or something else that you're forgetting. try getting context following a step-by-step, then see if it works
11th Mar 2017, 2:23 PM
Welliton Malta
Welliton Malta - avatar