Skip to Content
Head Rush Ajax
book

Head Rush Ajax

by Brett McLaughlin
March 2006
Beginner to intermediate
448 pages
13h 33m
English
O'Reilly Media, Inc.
Content preview from Head Rush Ajax
you’re on your way 4
259
developing dom apps
function addToTop5() {
var imgElement = this;
var top5Element = document.getElementById(“top5”);
}
Next, let’s get the “top5” <div> element from the
browser’s DOM tree. You’ll need to add the <img>
element that was clicked on to the “top5” <div>, and
then remove the <img>’s onClick handler, so it no
longer runs addToTop5() when it’s clicked.
Now you’ve got the CD cover
image and the “top5” <div> that
you need to add the cover to.
Finding the “top5” <div>
addToTop5()
this
1. When someone clicks on an
image, addToTop5() is run...
2. ...and addToTop5() uses
the “this” keyword...
3. ...and the “this” keyword
points back to the image
that was clicked on.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally

Publisher Resources

ISBN: 0596102259Errata PageSupplemental Content