More Content Manipulation - Appendices - Web Development with jQuery (2015)

Web Development with jQuery (2015)

Part IV. Appendices

Appendix F. More Content Manipulation

Method/Property

Description

Return Value

HTML

after(content[, content])

Inserts the specified content after each selected element. One or more content items can be specified for inclusion and will be inserted sequentially. Content items can be an HTML snippet, a DOM element object reference, or a jQuery object.

jQuery

after(function())

Executes a function that returns content to be inserted after the selected element(s). The content returned by the function can be an HTML string, a DOM element object reference, an Array of DOM element object references, or a jQuery object.
As with most jQuery callback functions, this refers to the current element within the callback function, and the callback function is provided with the argument list: offset, html.

jQuery

append(content[, content])

Appends the specified content after any existing content for each selected element. One or more content items can be specified for inclusion and will be inserted sequentially. Content items can be an HTML snippet, a DOM element object reference, or a jQuery object.

jQuery

append(function())

Executes a function that returns content to be appended. The content returned by the function can be an HTML string, a DOM element object reference, an Array of DOM element object references, or a jQuery object.
As with most jQuery callback functions, this refers to the current element within the callback function, and the callback function is provided with the argument list: offset, html.

jQuery

appendTo(selector)

Appends all the selected elements to the elements specified by the selector argument.

jQuery

before(content[, content])

Inserts the specified content before each selected element. One or more content items can be specified for inclusion and will be inserted sequentially. Content items can be an HTML snippet, a DOM element object reference, or a jQuery object.

jQuery

before(function())

Executes a function that returns content to be inserted before the selected element(s). The content returned by the function can be an HTML string, a DOM element object reference, an Array of DOM element object references, or a jQuery object.
As with most jQuery callback functions, this refers to the current element within the callback function, and the callback function is provided with the argument list: offset, html.

jQuery

clone([withDataAndEvents])

Clones the selected elements; returns the jQuery object including the clones you created. If the optional withDataAndEvents argument is true, then events and data are cloned as well.

jQuery

clone(
[withDataAndEvents],
[deepWithDataAndEvents]
)

Clones the selected elements; returns the jQuery object including the clones you created. If the optional withDataAndEvents argument is true, then events and data are cloned as well.
If the optional second argument is provided, the deepWithDataAndEvents argument controls whether children elements also have their events and data cloned. By default, this argument matches whatever is provided for the first value. The first value's default value is false.

jQuery

detach([selector])

Removes the selected elements from the DOM. This method keeps jQuery data for the associated elements around, which can be useful when it is desired to reinsert the elements in the DOM at a later time.

jQuery

empty()

Removes all child nodes from the selected elements.

jQuery

insertAfter(selector)

Inserts the selected elements after the elements specified by the selector argument.

jQuery

insertBefore(selector)

Inserts the selected elements before the selectors specified by the selector argument.

jQuery

prepend(content[, content])

Prepends the specified content before any existing content for each selected element. One or more content items can be specified for inclusion and will be inserted sequentially. Content items can be an HTML snippet, a DOM element object reference, or a jQuery object.

jQuery

prepend(function())

Executes a function that returns content to be prepended. The content returned by the function can be an HTML string, a DOM element object reference, an Array of DOM element object references, or a jQuery object.
As with most jQuery callback functions, this refers to the current element within the callback function, and the callback function is provided with the argument list: offset, html.

jQuery

prependTo(selector)

Prepends all the selected elements to the elements specified by the selector argument.

jQuery

remove([selector])

Removes the selected elements from the DOM. An optional selector can be provided to further filter the selection.

jQuery

replaceAll(selector)

Replaces the elements specified in the selector argument with the selected elements.

jQuery

replaceWith(content)

Replaces each selected element(s) with the specified HTML or DOM element(s). This method returns the jQuery object, which includes the element that was replaced.

jQuery

replaceWith(function())

A callback function that returns content that will replace the selected elements. The content returned by the callback function can be an HTML snippet, a DOM element reference, an Array of DOM element references, or a jQuery object.
As with most jQuery callback functions, this refers to the current element within the callback function, and the callback function is provided with the argument list: offset, html.

jQuery

unwrap()

Removes the selected element(s) parent element.

jQuery

wrap(wrappingElement)

Wraps each selected element with the specified element. The element can be a selector referencing another element, an HTML snippet, a DOM element object reference, or a jQuery object.
Note the distinction that the element must be capable of wrapping another element—for example, you couldn't use an <img/> element to wrap another element.

jQuery

wrap(function())

A callback function that returns content that wraps the selected elements. The content returned by the callback function can be an HTML snippet, a DOM element reference, or a jQuery object.
As with most jQuery callback functions, this refers to the current element within the callback function, and the callback function is provided with the argument list: offset.
Note the distinction that the element must be capable of wrapping another element—for example, you couldn't use an <img/> element to wrap another element.

jQuery

wrapAll(wrappingElement)

Wraps all the selected elements. The element used to wrap each element can be a selector referencing an element, an HTML snippet, a DOM element object reference, or a jQuery object.
Note the distinction that the element must be capable of wrapping another element—for example, you couldn't use an <img/> element to wrap another element.

jQuery

wrapInner(wrappingElement)

Wraps the inner contents of each selected element. The element used to wrap each element can be a selector referencing an element, an HTML snippet, a DOM element object reference, or a jQuery object.
Note the distinction that the element must be capable of wrapping another element—for example, you couldn't use an <img/> element to wrap another element.

jQuery

wrapInner(function())

A callback function that returns content that wraps the selected elements. The content returned by the callback function can be an HTML snippet, a DOM element reference, or a jQuery object.
As with most jQuery callback functions, this refers to the current element within the callback function, and the callback function is provided with the argument list: offset.
Note the distinction that the element must be capable of wrapping another element—for example, you couldn't use an <img/> element to wrap another element.

jQuery