if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) {
i || (i = 0);
var length = this.length;
if (i < 0) i = length + i;
for (; i < length; i++)
if (this[i] === item) return i;
return -1;
};
function testIndexOf()
{
var a =[1,2,3,4];
alert(a.indexOf(3));
}
<input type="button" value="测试获取数组下标" />
您可能感兴趣的文章: