Content can be inserted at various points in the document, relative to existing content, using a variety of jQuery methods built for each purpose.
There are two sets of insertion functions: one set for inserting content inside of other content, and one for inserting outside of other content.
append()
: Appends content to the inside of the matched elementsprepend()
: Prepends content to the inside of the matched elementsappendTo()
: Appends the specified content to the inside of the matched elementsprependTo()
: Prepends the specified content to the inside of the matched elements
after()
: Appends content to the outside of the matched elementsbefore()
: Prepends content to the outside of the matched elementsinsertAfter()
: Takes the specified content and appends it outside of the specified elementsinsertBefore()
: Takes the specified content and prepends it outside of the specified elements
This is paragraph 1
This is paragraph 2
This is paragraph 3
This is paragraph 4
This is paragraph 5