JQuery.trim() function is used to trim white spaces embedded along with the string . It will remove the spaces before and after the string.
var str = jQuery.trim("your string which need to be trim");
Lets see how to use it
// Add JQuery Reference
In the above example i have used html button click and I am trimming the string.