Want to remove white spaces from a string in jQuery? You can use the jQuery $. trim() function to remove all the spaces (including non-breaking spaces), newlines, and tabs from the beginning and end of the specified string. However, the whitespaces in the middle of the string are preserved.
<pre class="original">Paragraph of text with multiple white spaces before andafter.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.