I dynamically change the HTML content. But when I change the content, all the CSS styling is removed. How can I keep the CSS style when I change the content dynamically?
<div id="sample">
<a href="#" onClick="call()">Change it </a>
<p id="para"> I am paragraph </p>
</div>
p {
background-color: yellow;
}
function call(){
$("#para").replaceWith('oops css gone');
}
Here is the jsFiddle: http://jsfiddle.net/rajagopalx/6sbvtpp6/