Javascript trim

In programming trim is a string manipulation function. It will remove the leading and trailing spaces. JavaScript does not provide the trim functionality by default. Best 3 sample i have provided below, same you can use for trimming the string using javascript.

Sample 1: Using Jquery trim: If you are using jquery, you can use the trim as shown below.

Sample 2: Another sample for javascript trim. It uses the regex function to trim the string.

Sample 3: Below function return the trimmed string.

Hopes above approaches will helps for newbies. If you have any good idea just add comments.

Similar Topics:

Tags:

javascript trim
We will send you more information on Javascript trim.
Enter your email address:
This entry was posted in Javascript and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *