jQuery offers a rich set of insertion methods that cover every position relative to an element: before it, after it, at the start of its content, and at the end of its content. Understanding the difference between the two method families — target-centric and content-centric — helps you write more readable code.
Content-Centric Methods
These methods are called on the content you want to insert: .appendTo(target), .prependTo(target), .insertBefore(target), .insertAfter(target). The subject is the new content, and the argument is where it goes.
Target-Centric Methods
These are called on the container: .append(content), .prepend(content), .before(content), .after(content). The subject is the destination element, and the argument is what to insert.
.append()— insert at end of element's children.prepend()— insert at beginning of element's children.after()— insert after the element in the DOM.before()— insert before the element in the DOM
You can pass HTML strings, jQuery objects, or DOM nodes to all insertion methods. Passing an existing DOM element moves it rather than cloning it.