// 打印结果
console.log(depId);
["25", "12", "1", "18", "13"]
console.log(typeof(depId));
object
// 我的代码
var thisID=$(this).parent().attr("id");
depId.remove(depId.indexOf(thisID));
// 错误提示
TypeError: depId.remove is not a function
depId.remove ...;
jq 已经引入了啊 另外好像我其他地方也有用到是没问题的 火狐浏览器都是
GET jquery-1.8.3.min.js
200 OK
91.4 KB
127.0.0.1:80
为什么有的地方好用啊
js 数组哪来的remove
方法?用splice
和jq无关,depId
是一个array,并没有一个remove方法。
//Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
JavaScript
中的 Array
默认是没有 remove
函数的。可以使用上面的方式添加一个。