I. Summary
This series of articles will take you into the wonderful world of jquery, with many authors ' specific experiences and solutions, even if you can use jquery to find some cheats in your reading.
We often use scripting to handle a variety of business logic, the most common being the operations of arrays and objects. The jquery tool function provides a convenient condition for us to manipulate objects and arrays.
Two. Foreword
Most people simply use the jquery selector to select objects, or to animate the page. You often write many algorithms on your own when dealing with business logic. This article reminds you that jquery can also improve the efficiency of our manipulating objects and arrays. And you can extend some common algorithms to the jquery tool function, Implements the reuse of script functions.
Three. What is a tool function
A tool function is a function defined on a jquery object (that is, the variable "$"). These functions are tool class functions. For example, the most commonly used trim () function in C #:
$.trim(" text ");
There is no trim function to remove both front and back spaces in the original JavaScript. So this kind of commonly used tool function is called "Utilities" function. Corresponding to the jquery Official document:
Http://docs.jquery.com/Utilities
"$" is actually a property of the "Window" object, so the following sentences are equivalent:
$.trim(" text ");
window.$.trim(" text ");
window.jQuery(" text ");
jQuery.trim(" text ");
Four. Tool function classification
Tool functions are mainly divided into the following categories:
Browser and feature detection
Array and object manipulation
Test actions
String manipulation
URL Action
Unlike the previous chapters, this article does not enumerate the list of functions. Everyone in the application, such as the encounter to manipulate a string, you can first look up in the API document/utilities/string operations to find out whether the shortcut has provided a quick tool function. If you don't consider yourself developing again.
The following is a common tool function that is used in each category of the instance specific.
Five. browser and feature detection
The best of jquery is its cross-browser features, and usually we don't have to write different code for different browsers. But if it's a jquery developer or a plug-in developer, it's up to us to handle the browser differences to provide the user with cross-browser features.
jquery provides the following properties for obtaining browser attributes:
|
Jquery.support |
Version 1.3 new |
| Jquery.browser |
has been abolished |
|
JQuery.browser.version |
has been abolished |
| Jquery.boxmodel |
has been abolished |