【发布时间】:2016-09-25 02:17:36
【问题描述】:
我有以下对象:
[{
"id": 2,
"price": 2000,
"name": "Mr Robot T1",
"image": "http://placehold.it/270x335"
}, {
"id": 1,
"price": 1000,
"name": "Mr Robot T2",
"image": "http://placehold.it/270x335"
}]
我想要的是删除第一项(id = 1),结果是:
[{
"id": 2,
"price": 2000,
"name": "Mr Robot T1",
"image": "http://placehold.it/270x335"
}]
可以吗?
【问题讨论】:
-
转到 MDN 并阅读有关 Array.prototype 的信息。不要跑到 stackoverflow 问这样的基本问题。这也与jquery 无关。
-
你有一个对象数组,而不仅仅是一个对象。您要求删除数组中的一个索引项。见:
Array.prototype.splice() -
Bonsoir Elliot :
array.splice(0,1) -
@mayken 我试试这个功能
标签: javascript jquery object