Appendix A. Answers to Exercises
CSS and XPath are both acceptable answers.
parents()
prev()
find()
orchildren()
, depending on where the element exists in the hierarchy:children()
can be used for immediate children of the element, andfind()
can be used for either immediate children or descendents.not()
You would use the
eq()
method and supply the position of the element within the selection offset from zero as the first argument.siblings()
,prev()
,next()
,prevAll()
,nextAll()
Using the
add()
methodYes
It is not possible to attach multiple events of the same type to the same element using the traditional event model; however, some very keen programming creativity could overcome this limitation, if one were so inclined.
The ability to attach multiple events of the same type to the same element. There are other items addressed in the W3C's API, but I consider this to be the biggest.
In the traditional event model, and Microsoft's event model, each event is named with an on prefix, for example,
onclick
,onsubmit
,onchange
, and so on. In the W3C's event model, the on prefix is dropped, but the names are otherwise the same.The
bind()
method. It has a shorter name, and it drops the thirduseCapture
argument used in the W3C's Event API. Bonus points if you referred to theuseCapture
argument as "mostly useless."You can use the
trigger('focus')
method, or you can call thefocus()
method without any arguments. Bonus points if you looked in Appendix D and discovered thetriggerHandler() ...
Get Beginning JavaScript® and CSS 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.