SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 67 | Next

Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb

"Accelerated DOM Scripting with Ajax, APIs, and Libraries"

Browsers also
collapse multiple whitespace characters into a single space, except in
 tags. Whitespace between the
opening tag and the first non-whitespace character should be ignored. Although rendering whitespace is
consistent across browsers, what happens when you retrieve it via JavaScript isn??™t consistent. If you need
consistency in all browsers when manipulating text nodes, you need to normalize the string by trimming all
whitespace characters at the beginning and end of the string, along with replacing any nonspaces with
spaces and then compressing multiple spaces into a single space.
Handling Attributes
You have multiple ways of handling attributes. Agnostically, you have two methods of an element
that enable you to interact with attributes: getAttribute() and setAttribute().
Suppose that the following were the HTML:
My Link
You could retrieve the href attribute like this:
var a = document.getElementById("mylink");
var href = a.getAttribute("href");
Likewise, you can change the attribute using setAttribute() like so:
a.setAttribute("href", "newlink.html");
The HTML extensions to DOM Level 1 offer you a convenient shortcut to an element??™s
attributes:
var href = a.href;
CHAPTER 2 n HTML, CSS, AND JAVASCRIPT 32
I prefer the brevity of this approach (you might find this to be a recurring theme with me).
In the case of the href attribute, there are caveats for the way different browsers behave.


Pages:
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6