Chapter 13. Getting the Most from jQuery

jQuery greatly simplifies JavaScript programming, and provides web designers with a tool that lets them add sophisticated interactivity quickly and easily. But jQuery isn’t always simple, and you need a certain amount of knowledge to use it to its full extent. In this chapter, you’ll learn how to take jQuery further: how to use the jQuery documentation and how to take advantage of prepackaged interactivity with plug-ins, plus some useful tips and tricks for working with jQuery.

Useful jQuery Tips and Information

jQuery makes programming easier, but on top of that, there are ways you can make programming jQuery easier. Here are a few bits of information that give you insight into jQuery so you can get the most from it.

$() Is the Same as jQuery()

In the many articles and blog posts on jQuery out there on the Web, you may encounter code like this:

jQuery('p').css('color','#F03');

While you’re familiar with $(‘p’), which selects all the <p> tags on a page, you may be wondering about this jQuery() function. Actually, they are one and the same. The code above could also be written like this:

$('p').css('color','#F03');

$() is an alias for jQuery(), and the two are interchangeable. John Resig, the creator of jQuery, realized that programmers would be using the main jQuery function a LOT, so rather than force people to type jQuery() over and over, he decided the shorter $() would be a good substitute.

In practice, you can use either jQuery() or $(); it’s ...

Get JavaScript & jQuery: The Missing Manual, 2nd Edition 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.