Geeks With Blogs

News
Google

Aaron Li's Blog Write it down before I forget September 2007 Entries
Make your own Javascript trim() function
add this single line into Javascript portion,

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };

then test with

var mystring="test   ";
alert(mystring.trim());

Posted On Wednesday, September 5, 2007 8:19 PM

Copyright © Aaron Li | Powered by: GeeksWithBlogs.net