jQuery is namespaced behind the
jQuery variable, which is aliased with a dollar
$). Unlike libraries such as Prototype, jQuery doesn’t extend any
The other important thing to understand about jQuery is selectors. If you’re familiar with CSS, selectors will be second nature to you. All of jQuery’s instance methods are performed on selectors, so rather than iterating over elements, you can just use a selector to collect them. Any functions called on the jQuery selector will be executed on every element selected.
To demonstrate this, let me show you an example of adding a class name
selected to all the elements with the
foo. The first example will be in
So, you can see how jQuery’s selectors API greatly reduces the ...