Replace each element in the set of matched elements with the provided new content.
// <h3>Old Header</h3>
$('h3').replaceWith('<h2>New Header</h2>');
<h2>New Header</h2>
const $div = $.t('<div>', { class: 'new' });
$('.old').replaceWith($div);
<div class="new"></div>
| Parameter | Type | Description |
|---|---|---|
| newContent | string | element | SR | HTML string, DOM element, or SR object to replace each matched element. |
Returns: The original SR object (containing the removed elements) for chaining.