How to remove white spaces from a string in jQuery?

Posted by Prem Tiwari | Updated on

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.

Trimmed String




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.

Related Questions & Answers