{"data":[{"hotelfloorsid":"1","floorname":"Ground Floor"},{"hotelfloorsid":"2","floorname":"1st Floor"},{"hotelfloorsid":"9","floorname":"3rd Floor"}]}
我想基于hotelfloorsid从这个数组中删除元素。
答案 0 :(得分:1)
使用filter从数组中删除项目。
var data = //your object - e.g. {data:[array of data]};
var newData = data.data.filter(function(object) {
return object.hotelfloorsid == 1; //only include rooms where hotelfloorsid is 1
});