Thursday 28 April 2011

jQuery Misc Methods


jQuery Misc Methods

MethodDescription
data()Attaches data to, or gets data from, selected elements
each()Run a function for each element matched by the jQuery selector
get()Get the DOM elements matched by the selector
index()Search for a given element from among the matched elements
$.noConflict()Release jQuery's control of the $ variable
$.param()Creates a serialized representation of an array or object (can be used as URL query string for AJAX requests)
removeData()Removes a previously-stored piece of data
size()Return the number of DOM elements matched by the jQuery selector
toArray()Retrieve all the DOM elements contained in the jQuery set, as an array

jQuery Ajax Methods


jQuery AJAX Methods

AJAX is the art of exchanging data with a server, and update parts of a web page - without reloading the whole page.

The following table lists all the jQuery AJAX methods:

MethodDescription
$.ajax()Performs an AJAX request
ajaxComplete()Specifies a function to run when the AJAX request completes
ajaxError()Specifies a function to run when the AJAX request completes with an error
ajaxSend()Specifies a function to run before the AJAX request is sent
$.ajaxSetup()Sets the default values for future AJAX requests
ajaxStart()Specifies a function to run when the first AJAX request begins
ajaxStop()Specifies a function to run when all AJAX requests have completed
ajaxSuccess()Specifies a function to run an AJAX request completes successfully
$.get()Loads data from a server using an AJAX HTTP GET request
$.getJSON()Loads JSON-encoded data from a server using a HTTP GET request
$.getScript()Loads (and executes) a JavaScript from the a server using an AJAX HTTP GET request
load()Loads data from a server and puts the returned HTML into the selected element
$.param()Creates a serialized representation of an array or object (can be used as URL query string for AJAX requests)
$.post()Loads data from a server using an AJAX HTTP POST request
serialize()Encodes a set of form elements as a string for submission
serializeArray()Encodes a set of form elements as an array of names and values

jQuery CSS Methods


jQuery CSS Methods

The following table lists all the methods used to manipulate CSS properties.

MethodDescription
addClass()Adds one or more classes to selected elements
css()Sets or returns one or more style properties for selected elements
hasClass()Checks if any of the selected elements have a specified class
height()Sets or returns the height of selected elements
offset()Sets or returns the position (relative to the document) for selected elements
offsetParent()Returns the first parent element that is positioned
position()Returns the position (relative to the parent element) of the first selected element
removeClass()Removes one or more classes from selected elements
scrollLeft()Sets or returns the horizontal position of the scrollbar for the selected elements
scrollTop()Sets or returns the vertical position of the scrollbar for the selected elements
toggleClass()Toggles between adding/removing one or more classes from selected elements
width()Sets or returns the width of selected elements

jQuery HTML Methods


jQuery HTML Methods

The following table lists all the methods used to manipulate the DOM.
The methods below work for both HTML and XML documents. Exception: the html() method.

MethodDescription
addClass()Adds one or more classes (for CSS) to selected elements
after()Inserts content after selected elements
append()Inserts content at the end of (but still inside) selected elements
appendTo()Inserts content at the end of (but still inside) selected elements
attr()Sets or returns an attribute and value of selected elements
before()Inserts content before selected elements
clone()Makes a copy of selected elements
detach()Removes (but keeps a copy of) selected elements
empty()Removes all child elements and content from selected elements
hasClass()Checks if any of the selected elements have a specified class (for CSS)
html()Sets or returns the content of selected elements
insertAfter()Inserts HTML markup or elements after selected elements
insertBefore()Inserts HTML markup or elements before selected elements
prepend()Inserts content at the beginning of (but still inside) selected elements
prependTo()Inserts content at the beginning of (but still inside) selected elements
remove()Removes selected elements
removeAttr()Removes an attribute from selected elements
removeClass()Removes one or more classes (for CSS) from selected elements
replaceAll()Replaces selected elements with new content
replaceWith()Replaces selected elements with new content
text()Sets or returns the text content of selected elements
toggleClass()Toggles between adding/removing one or more classes (for CSS) from selected elements
unwrap()Removes the parent element of the selected elements
val()Sets or returns the value attribute of the selected elements (form elements)
wrap()Wraps specified HTML element(s) around each selected element
wrapAll()Wraps specified HTML element(s) around all selected elements
wrapInner()Wraps specified HTML element(s) around the content of each selected element

jQuery Effect Methods


jQuery Effect Methods

The following table lists all the methods used to create animation effects.
MethodDescription
animate()Performs a custom animation (of a set of CSS properties) for selected elements
clearQueue()Removes all queued functions for the selected element
delay()Sets a delay for all queued functions for the selected element
dequeue()Runs the next queued functions for the selected element
fadeIn()Gradually changes the opacity, for selected elements, from hidden to visible
fadeOut()Gradually changes the opacity, for selected elements, from visible to hidden
fadeTo()Gradually changes the opacity, for selected elements, to a specified opacity
hide()Hides selected elements
queue()Shows the queued functions for the selected element
show()Shows hidden selected elements
slideDown()Gradually changes the height, for selected elements, from hidden to visible
slideToggle()Toggles between slideUp() and slideDown() for selected elements
slideUp()Gradually changes the height, for selected elements, from visible to hidden
stop()Stops a running animation on selected elements
toggle()Toggles between hide() and show(), or custom functions, for selected elements