Friday, September 30, 2011

prependTo(<Content>)

prependTo(<Content> content) returns jQuery
Prepend all of the matched elements to another, specified, set of elements. This operation is, essentially, the reverse of doing a regular $(A).prepend(B), in that instead of prepending B to A, you're prepending A to B.

Example:

Prepends all paragraphs to the element with the ID "foo"

$("p").prependTo("#foo");

HTML:
<p>I would like to say: </p><div id="foo"><b>Hello</b></div>

Result:
<div id="foo"><p>I would like to say: </p><b>Hello</b></div>

No comments:

Post a Comment