YouTube

Got a YouTube account?

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

English subtitles

← Adding DOM Elements - Intro to jQuery

Get Embed Code
5 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. JavaScript is a remarkably powerful language for manipulating the DOM.
  2. However, with great power comes great confusing syntax?
  3. Yeah.
  4. It can be tricky to add elements to the DOM with plain old JavaScript
  5. because you first have to create a DOM node, add data to it, find a parent for
  6. it, and then finally add that node as a child to that parent.
  7. And each step happens pretty much independently.
  8. With jQuery, you can create new DOM nodes and
  9. simultaneously add them to the document with one simple method.
  10. I want you to experiment with four different methods for creating and
  11. adding new DOM nodes.
  12. .append(), .prepend(), .insertBefore(), and
  13. .insertAfter() give you four different places to add new DOM elements.