PROWAREtech
JavaScript: IE11 String.trim() Prototype/Function
Create the String.trim() prototype for Internet Explorer 11.
Still developing for IE11? Well, this prototype is used to remote whitespace from the beginning and end of a string.
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
};
}
Using the above code snippet:
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
};
}
alert(" 123 ".trim());
Comment