JavaScript Events and the DOM
In the next exercise, we will create an HTML structure from JavaScript code. When preparing to build a web page that has dynamically generated parts, you first need to create its template (which contains the static parts), and use
placeholders for the dynamic parts. The placeholders must be uniquely identifiable HTML elements (elements with the ID
attribute set). So far we have used the <div>
element as placeholder, but you will meet more examples over the course of this book.
Take a look at the following HTML document:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”> <html> <head> <title>AJAX Foundations: More JavaScript and DOM</title> </head> <body> Hello Dude! Here’s a cool list of colors for you: <br/> <ul> <li>Black</li> <li>Orange</li> <li>Pink</li> </ul> <...