HTML and CSS Reference
In-Depth Information
Figure 15.10 Getting elements by tag name:
Mozilla Firefox (left), Internet Explorer (right).
15.6.3 JavaScript Properties to Represent HTML Attributes
The attributes of an HTML element are accessible as properties in JavaScript. Table 15.5
lists the properties available to JavaScript to test an attribute.
Table 15.5 Properties to Represent HTML Attributes
Property
Description
Example
className
Represents the class of a CSS element
div2.className="blue";
div2 refers to an HTML element.
It is being assigned the CSS class
called blue (see Example 15.17)
dir
Specifies the text direction for a document;
for example, read left to right (English), or
right to left (Hebrew); ltr (left to right) or rtl
(right to left)
element.dir="ltr";
id
Value of the unique id of the current element
(see Section 15.6.1)
lang
Specifies the language in which the text of
the document is written; for example, en for
English, ja for Japanese, and sp for Spanish
if(document.lang=="ja")
Continues
 
 
Search WWH ::




Custom Search