删除数组中某一个指定的数
javascript原生写法:
Array.prototype.indexOf = function(val){
for(var i=0;i<this.length;i++){
if(this[i] == val){
return i
}
}
return -1;
}
Array.prototype.remove = function(val){
var index = this.indexOf(val);
if(index >-1){
rerurn this.splice(index,1);
}
}
var dd=['s','d','a','d']
dd.remove('s');
alert(dd)
JQ写法
var dd=['s','d','a','d']
dd.splice(jQuery.inArray('d',dd),1)