Appendix F. Manipulating Content

Method/Property

Description

Return 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 ...

Get Beginning JavaScript® and CSS Development with jQuery now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.