1. 程式人生 > >jQuery 工具函數

jQuery 工具函數

部分 desc hit character ace ble tor cti middle

jQuery.contains() : Check to see if a DOM element is a descendant of another DOM element.

僅僅支持文檔元素

Note: The first argument must be a DOM element, not a jQuery object or plain JavaScript object.

jQuery.each() : A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function‘s arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.

jQuery.extend() : Merge the contents of two or more objects together into the first object.

第一個參數為ture時,執行深拷貝,target為第二個參數

jQuery.globalEval() : Execute some JavaScript code globally.

jQuery.grep() : Finds the elements of an array which satisfy a filter function. The original array is not affected.

類似於es5 的filter

jQuery.inArray() : Search for a specified value within an array and return its index (or -1 if not found).

jQuery.isArray() : returns a Boolean indicating whether the object is a JavaScript array (not an array-like object, such as a jQuery object)

jQuery.isEmptyObject(): Check to see if an object is empty (contains no enumerable properties).

jQuery.isPlainObject() : Check to see if an object is a plain object (created using "{}" or "new Object").

jQuery.makeArray() : Convert an array-like object into a true JavaScript array.

jQuery.map() : Translate all items in an array or object to new array of items.

類似於es5 map方法 ,區別1)返回null時,值不被包含在結果中2)映射函數返回的如果是數組,則該數組被添加到結果數組中,而不是數組本身中

jQuery.merge() : Merge the contents of two arrays together into the first array.

jQuery.parseJSON() : Takes a well-formed JSON string and returns the resulting JavaScript value.

jQuery.proxy() : Takes a function and returns a new one that will always have a particular context.

類似於es5的bind,但它沒有像bind()方法那樣實現參數的部分應用。

jQuery.trim() : Remove the whitespace from the beginning and end of a string.

If these whitespace characters occur in the middle of the string, they are preserved

jQuery 工具函數