jQuery provides simple methods for attaching event handlers to selections.
When an event occurs, the provided function is executed. Inside the function,
this refers to the element that was clicked.
For details on jQuery events, visit http://api.jquery.com/category/events/.
The event handling function can receive an event object. This
object can be used to determine the nature of the event, and to
prevent the event's default behavior.
For details on the event object, visit http://api.jquery.com/category/events/event-object/.
jQuery makes it trivial to add simple effects to your page. Effects can use the built-in settings, or provide a customized duration. You can also create custom animations of arbitrary CSS properties.
For complete details on jQuery effects, visit http://api.jquery.com/category/effects/.
A jQuery plugin is simply a new method that we use to extend jQuery's prototype
object. By extending the prototype object you enable all jQuery objects
to inherit any methods that you add. Once the plugin is established,
whenever you call $() you're creating a new jQuery object, with your
plugin now method included along with all of jQuery's existing methods.
The idea of a plugin is to do something with a collection of elements.
You could consider each method that comes with the jQuery core
a plugin, like fadeOut or addClass.
You can make your own plugins and use them privately in your
code or you can release them into the wild. There are thousands
of jQuery plugins available online. The barrier to creating a plugin
of your own is so low that you'll want to do it straight away!
We're all familiar with the basic events, click, mouseover, focus, blur,
submit, etc., that we can latch on to as a user interacts with the browser.
Custom events open up a whole new world of event-driven programming.
In this chapter, we'll use jQuery's custom events system to make a simple
form designing application.
jQuery's family of UI interface libraries - jQuery UI for desktops, and jQuery Mobile for smartphones and tablets - offer a set of interactions, widgets, events, and animations to solve common user-interface challenges. Both are well-documented, thoroughly tested, and easy to use.