Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Appendix F. Manipulating Content

Appendix F. Manipulating Content

Method/PropertyDescriptionReturn Value
HTML
html()Returns the HTML contents, or innerHTML, of the first element of the selection. This method does not work on XML documents, but does work on XHTML documents.String
html(value)Sets the HTML contents of every selected element. This method does not work on XML documents, but does work on XHTML documents.jQuery
Text
text()Returns the text content of each selected element.String
text(value)Sets the text content of each selected element. HTML source code will not be rendered.jQuery
Inserting Inside
append(content)Appends the specified content to the inside of every selected element.jQuery
appendTo(selector)Appends all of the selected elements to the elements specified by the selector argument.jQuery
prepend(content)Prepends the specified content to the inside of each selected element.jQuery
prependTo(selector)Prepends all of the selected elements to the elements specified by the selector argument.jQuery
Inserting Outside
after(content)Inserts the specified content after each selected element.jQuery
insertAfter(selector)Inserts the selected elements after the elements specified by the selector argument.jQuery
before(content)Inserts the specified content before each selected element.jQuery
insertBefore(selector)Inserts the selected elements before the selectors specified by the selector argument.jQuery
Inserting Around
wrap(html)Wraps each selected element with the specified HTML content.jQuery
wrap(element)Wraps each selected element with the specified element from the DOM.jQuery
wrapAll(html)Wraps all of the selected elements with a single wrapper specified as HTML.jQuery
wrapAll(element)Wraps all of the selected elements with the specified element from the DOM.jQuery
wrapInner(html)Wraps the inner contents of each selected element with the specified HTML.jQuery
wrapInner(element)Wraps the inner contents of each selected element with the specified element from the DOM.jQuery
Replacing
replaceWith(content)Replaces each selected element with the specified HTML or DOM elements. This method returns the jQuery object including the element that was replaced.jQuery
replaceAll(selector)Replaces the elements specified in the selector argument with the selected elements.jQuery
Removing
empty()Removes all child nodes from the selected elements.jQuery
remove(selector)Removes the selected elements from the DOM.jQuery
Copying
clone()Clones the selected elements; returns the jQuery object including the clones you created.jQuery
clone(true)Clones the selected elements and their event handlers; returns the jQuery object including the clones you created.jQuery



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial