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

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

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

parentNode;
}
}
var el = document.getElementById('test');
el.onclick = evtHandler;
In this case, the event handler is attached to the entire list and acts as a catchall for anything
clicked within its borders. The currentElement variable stores the event target to start off
with. It??™s the lowest element in the stack. I check to make sure I have a valid element (I??™ll
explain why in a second) and I check whether the current element is not the element that fired
the event, evtElement. I do this because I want to check elements only from the source to the
element that fired the event. I could theoretically continue up the stack until I reach the top
(which I??™ll discover when the parentNode is equal to null, hence the check for whether the current
element exists at all).
In the loop, I check to see that the current element is the one I want by matching specific
criteria. In this case, I??™m checking whether the class name is theOne. If it is, I perform my
action and then break out of the loop (I have no reason to continue up the stack once I??™ve
found what I??™m looking for). If it??™s not the right element, I set the current element to the parent
element and start again from the top of the while loop.
Sometimes you??™ll know that the element you want will be a specific distance from the target
element. That is, it will always be the direct parent or it will always be the sibling.


Pages:
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6