JSFiddle - React, Tailwind, and code Playground

HTML

<div>
    Div
    <a href="#">Link</a>
</div>

JavaScript

$.fn.replaceWithPush = function(a) {
    var $a = $(a);

    this.replaceWith($a);
    return $a;
};

$('a').replaceWithPush('<span>Span</span>').css('border', '1px solid black');