HTML and CSS Reference
In-Depth Information
Figure 15.30 Paragraph 2 has been removed.
15.7.10 Scrolling with the Nodes
In the following example, all three layers of a a Web page are represented: the HTML
content layer, the CSS presentation layer, and the JavaScript behavioral layer. By using
the getElementById() method and a little node knowledge, a scrolling marquee is created
in Example 15.17. In Chapter 10, Example 10.11 we saw scrolling in the window's status
and title bar. Now we can scroll within the body of the document. The program creates
a message that will continuously scroll across the screen. The original message is placed
within a <div> container. By first identifying the HTML div element— getElement-
ById() —JavaScript can then reference its child node, which is the text of the message
( firstChild ). This is depicted in Figure 15.31.
parent node
div
child node
text
Figure 15.31 Referencing a child node requires first identifying the div element.
 
 
Search WWH ::




Custom Search