javascript - TypeError: depId.remove is not a function 求解决 谢谢 --?
伊谢尔伦
伊谢尔伦 2017-04-11 12:10:10
[JavaScript讨论组]
// 打印结果
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

为什么有的地方好用啊
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(3)
高洛峰

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 函数的。可以使用上面的方式添加一个。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号