Javascript – How to trim() white spaces from a string

javascriptjquerystringtrim

JavaScript doesn't seem to have a native trim() method. How can I trim white spaces at the start and end of a string with JavaScript?

Best Answer

The shortest form for jQuery:

string = $.trim(string);

Link