JSFiddle - React, Tailwind, and code Playground
HTML
<div id="mydiv">
initial content
</div>
<a href="#" id="action">change</a>
CSS
#mydiv{
border:1px solid red;
width:300px;
padding:5px;
}
JavaScript
var newcontent = 'this is the new content<br />with multiple lines<br />etc...<br />etc..<br />etc.';
$('#action').click(function(){
var $mydiv = $('#mydiv');
$mydiv.css('height', $mydiv.height() );
$mydiv.html( newcontent );
$mydiv.wrapInner('<div/>');
var newheight = $('div:first',$mydiv).height();
$mydiv.animate( {height: newheight} );
});