HTML and CSS Reference
In-Depth Information
This p element is also assigned attributes. The dir attribute with rtl means the text
will be displayed from the right side of the screen to the left, as would be used with
Arabic or Hebrew.
The getElementById() method uses the id of the first paragraph and returns a ref-
erence to it.
The first paragraph has a dir and style attribute. Using dir and style.fontSize , Java-
Script can get access to these attributes.
The second paragraph has also been assigned attributes. Using the dir and class-
Name properties, JavaScript can find the direction of the text, right to left, and the
name of the class that is used to style this paragraph. The className property can
also be assigned the name of a different class to change the style of the object. The
output is shown in Figure 15.11.
Figure 15.11 Displaying HTML attributes with JavaScript properties.
15.7 Modifying the DOM ( Appending, Copying,
and Removing Nodes)
You can create new nodes, make a clone of an existing node, insert a new node before
an existing node, remove a node, or replace a node. All of this is possible because the
W3C DOM introduced methods to modify the DOM. Table 15.6 lists the DOM methods.
For a complete list of DOM methods and an excellent resource, go to the JavaScript Kit
page at For another great
resource on how to modify the DOM, go to
Search WWH ::

Custom Search