Whenever I use the trim()
function on a string, it works fine with Chrome and Firefox but I get an error in IE8 saying :
Object doesn't support this property or method
Can anyone tell me why this happens and if there is a work around?
Whenever I use the trim()
function on a string, it works fine with Chrome and Firefox but I get an error in IE8 saying :
Object doesn't support this property or method
Can anyone tell me why this happens and if there is a work around?
if you want you can add jquery and use $.trim(....) this will work..
give you
Since, I was using jQuery, with the help of @nemo and @karesh-a I came up with:
IE8 doesn't support the trim function. Here's a polyfill:
Internet Explorer only started support for
trim()
from version 9.For reference, the MDN Polyfill for
String.prototype.trim()
is:and the support for it is: