1 //添加數組IndexOf方法 2 //整理 jquery中文網 3 if (!Array.prototype.indexOf) 4 { 5 Array.prototype.indexOf = function(elt /*, from*/) 6 { 7 var len = this.length >>> 0; 8 var from = Number(arguments[1]) || 0; 9 from = (from < 0) 10 ? Math.ceil(from) 11 : Math.floor(from); 12 if (from < 0) 13 from += len; 14 for (; from < len; from++) 15 { 16 if (from in this && 17 this[from] === elt) 18 return from; 19 } 20 return -1; 21 }; 22 }