trim function in javascript not working in ie8

sam
sam
Member
378 Points
48 Posts

Hi,

I am using trim() as

if ($("#Progressbar_Global").html().trim() == "") {

 

Not working in ie.

Views: 10217
Total Answered: 1
Total Marked As Answer: 1
Posted On: 10-May-2015 07:50

Share:   fb twitter linkedin
Answers
Brian
Brian
Moderator
2232 Points
14 Posts
         

Hi Sam,

IE8 doesn't support the trim function. Add following code in top of the page:

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

 

 

Posted On: 11-May-2015 00:44
it was helpful for me
 - nik  11-May-2018 20:46
 Log In to Chat