One of jQuery's specialties is letting you select page elements so you can work with them. Selecting page elements is a big part of online work. Until now almost all selection capabilities involved the getElementByID (), getElementsByName (), or some type of for each statement which all work but are limited, time consuming and take unnecessary overhead. jQuery on the other hand goes above and beyond these methods. In jQuery your able to select by descendants, by children, by specific text, by attribute, by attribute value, and even by position all by just one simple line of code changed based on what your selection.
$ ('p [language =' 'Portuguese'] ')
and then add the function or whatever action I want it to run. While it may not make things shorter it sure does simplify.
One of the most powerful selectors in my opinion is the 'checked selector, which lets you select checked boxes and selected radio buttons. Using this you can tell which elements are checked and which are not rather than the cumbersome "if value checked or if true" logic required prior to jQuery.
Here's a quick example:
Function count ()
alert ("You checked" +
$ ("input: checkeded"). length +
By entering this in a script tag and using the checked selector I can see how many check boxes were selected. The selectors in jQuery make it much easier to work online. I've talked about a few selectors here but there are so many more built into jQuery giving you a variety of ways to select elements.
If you're looking for a good book on jQuery you should check out Visual Quickstart Guide jQuery by Steven Holzner . Its provides a bunch of good examples.