首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

ie8下-indexOf 跟 trim()方法bug

2014-01-17 
ie8下-indexOf 和 trim()方法bugvar fileType $.trim(n.resourcesMapping.extension).toLowerCase()if(

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. 

热点排行