The trim() method removes whitespace from both sides of a string: code example
Example: The trim() method removes whitespace from both sides of a string:
var str = " Hello World! ";
alert(str.trim());
var str = " Hello World! ";
alert(str.trim());