ie8下-indexOf 和 trim()方法bug
var fileType = $.trim(n.resourcesMapping.extension).toLowerCase();if($.inArray(fileType,fileTypeList)=='-1'){//其他 row.find(".fileType").addClass('other');}else{ row.find(".fileType").addClass(fileType);}
?ie8真是各种吐槽无能
?
1.不识别object.trim();方法
?
解决方法:$.trim(object);
?
2.ie9以下没有indexOf()这个方法
jQuery.inArray( value, array [, fromIndex ] )Returns: NumberjQuery.inArray( value, array [, fromIndex ] )valueType: AnythingThe value to search for.arrayType: ArrayAn array through which to search.fromIndexType: NumberThe index of the array at which to begin the search. The default is 0, which will search the whole array.?
PS:注意
?
The $.inArray() method is similar to JavaScript's native .indexOf() method in that it returns -1 when it doesn't find a match. If the first element within the array matches value, $.inArray() returns 0.
?
Because JavaScript treats 0 as loosely equal to false (i.e. 0 == false, but 0 !== false), if we're checking for the presence ofvalue within array, we need to check if it's not equal to (or greater than) -1.