O'Reilly logo

DOM Scripting: Web Design with JavaScript and the Document Object Model, Second Edition by Jeffrey Sambells, Jeremy Keith

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

Chapter 7. Creating Markup on the Fly

What this chapter covers:

  • A quick look at the "old-school" techniques: document.write and innerHTML

  • An in-depth look at the DOM methods createElement, createTextNode, appendChild, and insertBefore

  • An introduction to Ajax and asynchronous requests

Most of the DOM methods you've seen so far are useful for identifying elements. Both getElementById and getElementsByTagName allow you to quickly and easily target specific element nodes in a document. These elements can then be manipulated using methods and properties like setAttribute (to change the value of an attribute) or nodeValue (to change the text contained by an element node). That's how the image gallery works. The showPic function identifies two elements, ...

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