When using the href property, the full resolved URL is returned. For example, a.href would
return "http://example.com/link.html". When using the getAttribute() method, IE still
returns the fully resolved URL, but Mozilla Firefox returns only the exact value of the attribute.
For this reason, I use a.href for consistency.
nNote There are a few differences in what the attribute property and what the getAttribute method
return. This mostly comes back to problems with the way IE has implemented those features. For example,
getAttribute("class") should work, but because IE simply maps the method to the attribute property,
and because class is a reserved word, it doesn??™t work. Instead, you have to specify className. Tobie
Langel and Andrew Dupont delve deep into the issue on Tobie??™s site: http://tobielangel.com/2007/
1/11/attribute-nightmare-in-ie.
The style Property
Each element in the DOM has a style property that enables you to style the elements dynamically.
All the CSS properties are available through the style property.
element.style.height = '100px'; // sets the height to 100 pixels
element.style.display = 'none'; // hides the element from the user
JavaScript doesn??™t like hyphens in methods or properties, so any hyphenated CSS properties
have the hyphen removed and the first letter of the second word capitalized??”this format
is also known as camel case.
element.style.backgroundColor = '#FF0000'; // background is red
element.
Pages:
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80