/ Published in: JavaScript
sample:
var text = " string content ";
text = text.trim();
var text = " string content ";
text = text.trim();
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } String.prototype.ltrim = function() { return this.replace(/^\s+/,""); } String.prototype.rtrim = function() { return this.replace(/\s+$/,""); }