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

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

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

This continues until the user has met the total possible number
of matches (totalMatches).
Halfway Between Here and There
Things get a little trickier when the element you??™re looking for is between the source element
and the element that handled the event. Luckily, it??™s not all that complicated. All you have to
know is how to identify the element you want, which can be through an ID, through a class
name, or through a predictable HTML structure.
To get to the element that you want, start from the target and work your way back up the
tree using parentNode, checking each time to see whether the element has been clicked.
Take this rather straightforward list of items, for example:

In this case, you can see whether the user clicks any list item that has the class name of
theOne. You can grab all the elements, loop through each one to determine whether it has the
class name of theOne, and attach an event handler to it. Or you can use event delegation.
function evtHandler(evt)
{
evt = evt || window.event;
var currentElement = evt.target || evt.srcElement;
var evtElement = this;
while(currentElement && currentElement != evtElement)
{
if(currentElement.className == 'theOne')
CHAPTER 2 n HTML, CSS, AND JAVASCRIPT 54
{
alert('I have got one!');
break; // break out of the while statement
}
currentElement = currentElement.


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