In the next exercise, we will create a simple HTML structure from JavaScript code using the DOM. When creating 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).
The typical elements used as placeholders are <div>
and <span>
, due to their generic usage purpose. In practice they’re typically used in conjunction with CSS to customize the appearance of the displayed content. The <div>
and <span>
elements are nicely (and briefly) described at
http://en.wikipedia.org/wiki/Span_and_div
.
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 Tutorial: JavaScript Events and DOM</title>...