Skip to content

jquery_ref_misc

jQuery provides several utility methods for common tasks that don’t fit neatly into other categories like DOM manipulation or AJAX.

Method / PropertyDescription
.data()Store arbitrary data associated with the matched elements or return the value for the first element in the set.
.removeData()Remove a previously-stored piece of data.
.each()Iterate over a jQuery object, executing a function for each matched element. Inside the function, this refers to the current DOM element.
$.each()A generic iterator function, which can be used to seamlessly iterate over both objects and arrays.
.get()Retrieve the DOM elements matched by the jQuery object. Without arguments, returns an array; with an index, returns a single DOM element.
.index()Search for a given element from among the matched elements, returning its zero-based index. Can also find the index of an element relative to its siblings.
$.noConflict()Relinquish jQuery’s control of the $ variable, allowing other libraries that use $ to coexist.
$.param()Create a serialized representation of an array, a plain object, or a jQuery object suitable for use in a URL query string or Ajax request.
.toArray()Retrieve all the DOM elements contained in the jQuery set as a standard JavaScript array.
.length(Property, not method) Returns the number of elements in the jQuery object. This replaces the deprecated .size() method.
$.map()Translate all items in an array or object to new array of items.
$.trim()Utility function to remove whitespace from the beginning and end of a string. (Note: Native JS String.prototype.trim() is usually preferred now).
$.type()Determine the internal JavaScript [[Class]] of an object.
$.isFunction()Check if the argument is a JavaScript function.
$.isArray()Check if the argument is a JavaScript array. (Note: Native Array.isArray() is usually preferred now).
$.isNumeric()Check if the argument is a numeric value.
$.proxy()Takes a function and returns a new one that will always have a particular context (this value). Less commonly needed with ES6 arrow functions or Function.prototype.bind.

Note: Some jQuery utility functions have equivalents in modern standard JavaScript (e.g., Array.isArray, String.prototype.trim). While the jQuery versions work reliably across older browsers, consider using the native JavaScript versions when appropriate for potentially better performance and adherence to modern standards.