How to remove leading and trailing rendered as white spaces from a given HTML string? [closed]
See the String method trim() – https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Trim var myString = ‘ bunch of <br> string data with<p>trailing</p> and leading space ‘; myString = myString.trim(); // or myString = String.trim(myString); Edit As noted in other comments, it is possible to use the regex approach. The trim method is effectively just an alias for a regex: if(!String.prototype.trim) … Read more