Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim to remove white space

Tags:

jquery

trim

jQuery trim not working. I wrote the following command to remove white space. Whats wrong in it?

var str = $('input').val();  str = jquery.trim(str); console.log(str); 

Fiddle example.

like image 808
Akhil K Nambiar Avatar asked Oct 28 '10 06:10

Akhil K Nambiar


People also ask

Does trim get rid of spaces?

The TRIM function can get rid of white spaces, but it cannot eliminate non-printing characters. Technically, Excel TRIM is designed to only delete value 32 in the 7-bit ASCII system, which is the space character. To remove spaces and non-printing characters in a string, use TRIM in combination with the CLEAN function.

How do you strip whitespace from the beginning and end of a string?

String result = str. trim(); The trim() method will remove both leading and trailing whitespace from a string and return the result.


1 Answers

jQuery.trim() capital Q?

or $.trim()

Edit (2021): This answer is 11 years old (2010). There are better solutions posted below.

like image 87
Jason Avatar answered Oct 04 '22 01:10

Jason