How do you place a canvas element with an ID of canvas1 into a JavaScript variable?

Q & AHow do you place a canvas element with an ID of canvas1 into a JavaScript variable?
Admin Staff asked 3 years ago

How do you place a canvas element with an ID of canvas1 into a JavaScript variable?

A. var canvas1 = document.getElementById(‘canvas1’);

B. var canvas1 = document.get(‘#canvas1’);

C. var canvas1 = getElementById(‘canvas1’);

D. var canvas1 = document.getElement(‘canvas1’);

1 Answers
Admin Staff answered 3 years ago

A. var canvas1 = document.getElementById(‘canvas1’);