jQuery in Action, Third Edition

jQuery in Action, Third Edition

English | 2015 | ISBN: 978-1617292071 | 504 Pages | PDF | 10 MB

jQuery in Action, Third Edition, is a fast-paced guide to jQuery, focused on the tasks you’ll face in nearly any web dev project. In it, you’ll learn how to traverse the DOM, handle events, perform animations, write jQuery plugins, perform Ajax requests, and even unit test your code. Its unique Lab Pages anchor each concept in real-world code. This expanded Third Edition adds new chapters that teach you how to interact with other tools and frameworks and build modern single-page web applications.
What’s Inside

  • Updated for jQuery 3
  • DOM manipulation and event handling
  • Animations and effects
  • Advanced topics including Unit Testing and Promises
  • Practical examples and labs

Introducing jQuery

  • What exactly jQuery is and why you should use it
  • The unobtrusive JavaScript strategy
  • Choosing the right version of jQuery
  • Fundamental elements and concepts of jQuery

We mentioned how well the repository of the library and the code in general are organized. We also paid great attention to the several available versions of the library and their differences in order to be able to make a conscious choice. Performance is an important factor to consider, so we described the possibilities you have to reduce the added overhead to a minimum by including a library in your pages. Using CDNs and customizing the modules that you want are an amazing way to speed up the download of jQuery.

In the chapters that follow, we’ll explore all the features that jQuery has to offer you as a web developer. We’ll begin our tour in the next chapter as you learn how to use jQuery selectors to quickly and easily identify the elements that you wish to act on

Core jQuery

A good number of the capabilities required by interactive web applications are achieved by manipulating the DOM elements that make up the pages. But before they can be manipulated, they need to be identified and selected. This and the next chapter provide you with the concepts to select elements. In the previous edition of this book, they were a unique chapter because their contents are highly related, but we decided to split them to help you digest the huge number of concepts described. Note that, despite the split, this chapter is still pretty long and terse. You may expect to go through it several times before mastering all its concepts. With this last note in mind, let’s begin our detailed tour of the many ways that jQuery lets you specify which elements are to be targeted for manipulation.

In JavaScript, you have a set of functions, such as getElementById() and getElementsByClassName() , that are designed to work with a specific type of selector to retrieve DOM elements to act upon. Unfortunately, you might have some problems using even such simple functions. For example, getElementsByClassName() isn’t supported in versions of Internet Explorer prior to 9. If you want to use only native methods, you should pay attention to cross-browser compatibilities.

jQuery to the rescue! If the browser supports the selector or the function natively, jQuery will rely on it to be more efficient; otherwise it’ll use its methods to return the
expected result. The good news is that you don’t have to worry about this difference. jQuery will do its work for you behind the scenes, so you can focus on other aspects of
your code.