Cover by John Resig and Bear Bibeault

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Chapter 14. Manipulating the DOM

This chapter covers

  • Injecting HTML into a page
  • Cloning elements
  • Removing elements
  • Manipulating element text

If we were to open up a JavaScript library, we’d certainly notice (most likely with some surprise) the length and complexity of the code behind simple DOM operations. Even presumably simple code, like cloning or removing a node (which both have simple DOM counterparts, like cloneNode() and removeChild()), have relatively complex implementations.

This raises two questions:

  • Why is this code so complex?
  • Why do I need to understand how it works if the library will take care of it for me?

The most compelling reason is performance. Understanding how DOM modification works in libraries can allow you to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required