$.trim(value);
The above jquery code would trim the text. I need to trim the string using Javascript.
I tried:
link_content = " check ";
trim_check = link_content.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,'');
How to use trim in javascript? Equivalent of $.trim() of jQuery?
JavaScript 1.8.1 includes the trim method on String objects. This code will add support for the trim method in browsers that do not have a native implementation: