Chapter 22. Introduction to jQuery

Powerful and flexible as JavaScript is, with its plethora of built-in functions and the continuing improvements being made to it, you often still need additional layers of code for simple things that cannot be achieved natively or with CSS, such as animations, event handling, and asynchronous communication.

What’s more, as a consequence of the various browser wars over the years, frustrating and annoying browser incompatibilities have come and gone, rearing their heads at different times on different platforms and programs.

As a result, ensuring your web pages look the same on all devices can sometimes be achieved only through tedious JavaScript code that accounts for all the discrepancies across the range of browsers and versions released over recent years. Yes, much has been done to resolve these differences, but even today every responsive site I create still needs exceptions to handle the different browsers, unless I use a framework, as I’m sure many would agree.

To fill these gaps, a number of libraries of functions (many of which also provide easy hooks into the DOM) have been developed to minimize the differences between browsers and to facilitate asynchronous communication and event and animation handling, such as the subject of this chapter, jQuery.

Note

Sometimes there is a simple JavaScript-based solution to the problem you are trying to solve. One way to check whether this is the case is to make a search at youmightnotneedjquery.com ...

Get Learning PHP, MySQL & JavaScript, 6th 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.