Javascript: 101 Week 4

Since track 2 is the subset for track 1 in week 4, so we combine them both to this post.

On this week, beside watching 'An Incovenient API - The Theory of the DOM' as below by Douglas Crockford, we also need to reading these articles below on understanding on DOM.


  1. There were two key innovations to the original (fetch-parse-flow-paint) linear workflow that the Mosaic browser used to render web pages. One allowed for a perception of faster rendering, and the other allowed for us to use AJAX. Explain both? This article, The Inconvenient Truth on website performance, do explain clearly.

  2. What are the roles of 'name' and 'id' attributes in HTML tags? What is an appropriate use of both? From bytes's forum, Douglas Crockford said "name is used to annotate POST data in forms. id is used to identify elements for scripting and styling. Some browsers used them interchangeably, which is confusing."

  3. Which pointers does each node in the DOM tree typically have? From Aticle: Traversing the DOM, each node in the DOM tree typically point to 'parent', 'child' and 'sibling'.

  4. Given a node object from a DOM tree, how do we determine if it is a text node or a regular node? From Aticle: Traversing the DOM, a text node’s nodeName property is "#text".


  • Download the source for the web page ''. In the source page itself, write a Javascript function which counts the number of text nodes in the document and shows the count in an alert dialogue. You can choose how you want to trigger the function (through a button click, link click, or any other event).

  • Change the example above so that instead of displaying the count in an alert dialogue, it is displayed in a span tag in the HTML page itself.

  • Add a link besides the button, such that when the link is click, it changes the style on the span tag to make it's contents bold.



Comments powered by Disqus