Possible duplicate:How to trim a string in javascript?
I need to remove only from the last and first spaces from the common line.
Example:
var str = " hello world "; // become "hello world" var str = "ehi, do you come from ? "; // become "ehi, do you come from ?" var str = "I am from Cina"; // remain "I am from Cina"
How can i do this?
jQuery cropping is what you are looking for.
$.trim(' string with spaces at the ends ');
Or simple javascript:
' string with spaces at the ends '.trim()