Wednesday, August 29, 2012

Manipulate Element in jQuery

Here are some frequently used functions in jQuery to handle DOM elements
  1. empty() removes all child elements and other child nodes (such as text nodes) from each element in the matched set, leaving the selector element empty
  2. remove() removes matched elements and child nodes, deletes all jQuery data and events associated with the removed elements
  3. detach() behaves exactly like remove(), except that it doesn't delete the jQuery data and events associated with the removed elements (for later use)
  4. unwrap() function removes the parent of an element (or the parents of a set of elements) from the DOM
  5. replaceWith() lets you replace an element, or set of elements, with new content.
  6. replaceAll() does the same job as replaceWith(), but you pass in the elements that you want to replace
  7. Adding content at the start of an element (or elements) with prepend() and prependTo()
  8. Adding content at the end of an element (or elements) with append() and appendTo()
  9. Adding content before an element (or elements) with before() and insertBefore()
  10. Adding content after an element (or elements) with after() and insertAfter() 
  11. Wrapping content around an element (or elements), or around an element's contents, with wrap(), wrapAll() and wrapInner()

No comments:

Post a Comment