264
Chapter 4.5
function addToTop5() {
var imgElement = ___________;
var top5Element = document.getElementById(___________);
top5Element.__________________________;
imgElement._____________ = ________;
}
Did you have any trouble with the Top 5 CDs test drive? If you
did, make sure you put the code magnets in the right blanks,
and update your JavaScript code to match.
this
that
“top5”
onclick
addToTop5
top5Element
top5-listings
imgElement
These are leftover magnets.
Using null removes any other
handlers for onclick, so now the
addToTop5() method won’t run
when the image is clicked on.
Once the CD is in the
Top 5, it doesn’t need an
event handler anymore.
The <img> element that was clicked on gets moved
to the end of the top5Element’s child list.
Code
Magnets
Solutions
null
nshing addToTop5()
append ...