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 62 | Next

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

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


??? getElementsByTagName(): Retrieves all elements of a specific tag name. The W3C
specification indicates that HTML processors generally assume uppercase elements.
In current browsers, both uppercase and lowercase tag names will work. However, in
XHTML, the tag name must be lowercase. Therefore, I recommend that you use
lowercase.
??? childNodes: A property that retrieves all nodes that are direct descendants of an
element.
CHAPTER 2 n HTML, CSS, AND JAVASCRIPT 28
73ed30358d714f26dd2d9c0159f8cfe0
To see some of these functions in action, you need a document to work on:


Welcome to my web site


We sell all the widgets you need.





Now let??™s play with the document a little bit:
var mainContent = document.getElementById("main");
mainContent.style.backgroundColor = '#FF0000';
var paragraphs = document.getElementsByTagName("p");
for(i=0;i{
paragraphs[i].style.fontSize = '2em';
}
var elements = document.getElementsByTagName("body")[0].childNodes;
for(i=0;i{
if(elements[i].nodeType == 1 && elements[i].id) alert(elements[i].id);
}
First up, you grab the
with an ID of main and change the background color to
red. Next, you grab all the paragraph elements, loop through each one, and set the font
size to 2 ems.


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