/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
String.prototype.trim = function() { // skip leading and trailing whitespace // and return everything in between var trimmedString = this; trimmedString = trimmedString.replace(/^\s+/,""); trimmedString = trimmedString.replace(/\s+$/,""); return trimmedString; }