How do i use query selector


document.getElementById("MyCanvas"); , i'm new and there are alot of things i do not know, how do ppl know when to use what with what method , e.g. when using getElementByID .. its always ("MyCanvas") , or when using getContext... always "2d"... how do ppl know what is the word for those method..


getElementById is a build in javascript function is selects based on the id name. If you have a html element:


you can give a element an id:

<canvas id="MyCanvas"></canvas>

so you create the name for the element to select with getElementById. If you don't know id's, you might want to read a bit about them