string method to remove whitesapce 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());