YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Interfacing to the DOM - HTML5 Game Development

Get Embed Code
7 Languages

Showing Revision 9 created 05/24/2016 by Udacity Robot.

  1. So, the first thing we do, is grab the body dom object using
  2. document.getElementById, with an id of body, and we create a div object, as well
  3. as a canvas object, and set their id's appropriately to div.id = "gameContent"
  4. and canvas.id = "gameCanvas" and finally, we append the div object to the body
  5. and the canvas object to the div. If we open this up into our browser, we can
  6. see that we have indeed created a div element and inside that is our new canvas
  7. element and both with a proper id.