JSFiddle - React, Tailwind, and code Playground

HTML

<b class="foo bar" data-test="{}" style="color:blue;">Hello<br><strong>World!</strong></b>
<a href="#">Former Link</a>
<input href="#">
<span class="img" src="https://www.gravatar.com/avatar/b7e5fd5f16fc6e3e723038d961558995?s=128&d=identicon&r=PG">
  <i>Looks funny in Inspector</i>
</span>

JavaScript

(function($) {

$.fn.changeElementType = function( newType ){
  var $this = this;

  this.each( function( index ){

    var atts = {};
    $.each( this.attributes, function(){
      atts[ this.name ] = this.value;
    });

    var $old = $(this);
    var $new = $('<'+ newType +'/>', atts ).append(  $old.contents()  );
    $old.replaceWith( $new );

    $this[ index ] = $new[0];
  });

  return this;
};

})(jQuery);


$('a,b').changeElementType('div');
$('input').changeElementType('a').text('Link Text');
$('.img').changeElementType('img');