Java Reference
In-Depth Information
alert("We're sorry, but " + response.searchTerm + " is not available.");
}
}
jQuery is an extensive framework, and adequately covering the topic in depth requires much
more than this chapter can provide. Entire books are devoted to jQuery! However, the jQuery
documentation is quite good, and you can view it at http://docs.jquery.com . jQuery's website
also lists a variety of tutorials, so don't forget to check them out at http://docs.jquery.com/
Tutorials .
summarY
This chapter introduced you to jQuery, the most popular JavaScript library.
You learned where and how to obtain jQuery and reference it in your pages.
You also learned about jQuery's $() function, and how it is central to jQuery's functionality.
jQuery popularized using CSS selectors to find elements within the DOM, and you learned
how find elements with the $() function.
You can change element styles with either the css() method, or by modifying the CSS classes
with the addClass() , removeClass() , and toggleClass() methods.
Cross‐browser events can be a drag when dealing with older browser versions, but jQuery
make registering event listeners and working with event data easy (and mostly standards
compliant).
jQuery also simplifies Ajax with its get() and getJSON() methods, and you learned that
getJSON() automatically parses the response into a JavaScript object.
You learned about deferred objects. You also learned about the “done,” “fail,” and
“always” queues, and how you can chain them together to assign multiple handlers to the
different queues.
exerCises
You can find suggested solutions for these questions in Appendix A.
1. Example 1 is based on Chapter 10's Example 17, and as you probably remember, you modified
that example in response to one of Chapter 10's exercise questions. Modify this chapter's
Example 1 so that only one tab is active at a time.
2. There is some repetitive code in Example 2. Refactor the code to reduce the duplication.
Additionally, add a function to handle any errors that may occur with the request.
 
 
 
Search WWH ::




Custom Search