JSFiddle - React, Tailwind, and code Playground
HTML
<div id="sample">
<a href="#" onClick="call()">Change it </a>
<p id="para" class="highlight">I am paragraph</p>
</div>
CSS
.highlight {
background-color: yellow;
}
JavaScript
function call(){
var replacedElement = $("<div />");
var storedClass = $("#para").attr("class");
replacedElement.text("yeah css still there");
replacedElement.attr("class",storedClass);
$("#para").replaceWith(replacedElement);
}