Appendix A
Exercise Answers
Chapter 2
- CSS and XPath are both acceptable answers.
parents()
prev()
children()
for immediate descendants andfind()
for any elements in the descendant hierarchynot()
eq()
siblings()
,prev()
,next()
,prevAll()
,nextAll()
add()
Chapter 3
- You can use the
mouseover()
oron('mouseover')
method. If you use deprecated methods, in addition, you can usebind('mouseover')
orlive('mouseover')
.Extra Credit: Use the
hover()
method. - The
on()
method. - The
event.target
property is used to check to see which descendant element has received the event. The event then bubbles up from that element to the element that the event handler is attached to. - Provide a selector argument to the
on()
method describing the element you want the event to apply to on the parent or container element that contains the elements you want the event to apply to. This can also be thedocument
object. - Naming an instance of an event handler can be done by applying the event name, a dot, and then the namespace you want to use. You can apply multiple event names by repeating the same process.
- The
off()
method. - Yes.
- You can use either
click()
with no arguments ortrigger('click')
. - A custom event handler begins with any event name not already in use in JavaScript; you can attach a custom event handler using that name using the
on()
method. Thetrigger()
method can be used to fire the custom event handler, as well as to send custom data to the event handler.
Chapter 4
- One possibility: ...
Get Web Development with jQuery now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.