DOM manipulation methods in a nutshell

The extensive DOM manipulation methods that jQuery provides vary according to their task and their target location. We haven't covered them all here, but most are analogous to the ones we've seen, and more will be discussed in Chapter 12, Advanced DOM Manipulation. The following outline can serve as a reminder of which method we can use to accomplish which task:

  • To create new elements from HTML, use the $() function
  • To insert new elements inside every matched element, use the following functions:
    • .append()
    • .appendTo()
    • .prepend()
    • .prependTo()
  • To insert new elements adjacent to every matched element, use the following functions:
    • .after()
    • .insertAfter()
    • .before()
    • .insertBefore()
  • To insert new elements around every matched ...

Get Learning jQuery - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.