Описание тега replacewith

JQuery .replaceWith() method. Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed.

JQuery.replaceWith() method. Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed.

The.replaceWith() method, like most jQuery methods, returns the jQuery object so that other methods can be chained onto it. However, it must be noted that the original jQuery object is returned. This object refers to the element that has been removed from the DOM, not the new element that has replaced it.

As of jQuery 1.4,.replaceWith() can also work on disconnected DOM nodes.

Source: http://api.jquery.com/replaceWith/