In jQuery, tool functions refer to methods that are directly attached to the jQuery object and defined for the jQuery object itself, that is, global. We collectively call them tool functions, or Utilites functions
Mainly used for: strings, arrays, objects
API: Utility function
Call format:
$.functionname() or jQuery.functionname()
String operations:
$.trim(): Remove the spaces on the left and right sides of the string
Array and object operations:
$.each(): Traverse the array
$.each(array,function(index,value){}): array: array variable, index: element subscript, starting from 0, value: element value
$each(): Traverse the object
$each(object,function(name,value){}): object: object, name: attribute name, value: attribute value
$.grep(): Data filtering: Returns a filtered array
$.map(): Modify data
$.inArray(): Find the subscript of the element
$.inArray(value,array): value: element value, array: array to search for, returns the subscript of the element in the array, starting from 0
$.merge(): Merge two arrays
$.merge(array1,array2): Add the second array to the first array
$.unique(): Remove duplicate DOM elements
$.unique(dom):dom:DOM element
Selector.toArray(): Combine multiple DOM elements into an array and return the innerHTML of the array elements
Test operation:, return boolean
$.isArray(): Determine whether it is an array object and return boolean
$.isArray(object): object: the object being judged
$.isFunction(): Determine whether it is a function and return boolean
$.isFunction(object): object: the object being judged
$.isEmptyObject(): Determine whether it is an empty object and return boolean
$.isEmptyObject(object): object: the object being judged
$.isPlainObject(): Determine whether it is a pure object and return boolean
Pure objects: objects created by {} or new Object(), such as "var obj = {}" or "var obj = new Object()"
$.contains(): Determine whether the DOM node contains another DOM node
$.contains(dom1,dom2): Whether the dom1 node contains the dom2 node
$.type(): Output data type, return the data type of the object
$.isNumeric(): Determine whether it is a numeric type
$.isWindow(): Determine whether it is a Window object
Window object: represents the window opened in the browser
URL operation:
$param(): Convert the key-value pair of the object into a URL key-value pair string form
$param(object): object: the object that needs to be converted
Browser Action: Deprecated
Other operations:
$.proxy(): Adjust the pointing of this
When an external event triggers a call to an object method, there will be a problem with this pointing (the triggered object will be called)
The above is the entire content of this article, I hope you all like it.