How to remove space from begin and end of string using jQuery trim

Below jQuery code remove spaces from begin and end of string using trim function of jQuery.
$(document).ready(function(){
   var strVal = "     jQuery By Example     ";
   strVal = jQuery.trim(strVal);
   alert(strVal);
});

When you run this code, "jQuery By Example" will be displayed in alert box. trim() will remove the space from begin and end of any string. Spaces within the string variable will be ignored.
See live Demo and Code
Feel free to contact me for any help related to jQuery. I will gladly help you.
SHARE

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..