博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

ie数组不支持indexOf 方法解决

Posted on 2016-07-04 16:44  绝交  阅读(276)  评论(0编辑  收藏  举报

if(!Array.prototype.indexOf){

  Array.prototype.indexOf = function(obj){

    for(var i=0;i<this.length;i++){

      if(this[i] == obj){

        return i;

      }

    }

    return -1;

  };

}