Edit in JSFiddle

<p>    Hi All, how are you       </p>
<button>Remove whitespace</button>
<div></div>
$("button").click(function(){
var str=$('p').html();
var trimedstr=jQuery.trim(str);
$("div").html('Trimed string :'+trimedstr);
});