HTML and CSS Reference
In-Depth Information
EXPLANATION ( CONTINUED )
3
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.
4
The getElementById() method uses the id of the first paragraph and returns a ref-
erence to it.
5
The first paragraph has a dir and style attribute. Using dir and style.fontSize , Java-
Script can get access to these attributes.
6
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 http://www.JavaScriptkit.com/domref/elementmethods.shtml. For another great
resource on how to modify the DOM, go to http://www.howtocreate.co.uk/tutorials/Java-
Script/dombasics.
 
 
Search WWH ::




Custom Search