从jQuery每个循环中删除item [i] [英] Remove item[i] from jQuery each loop

查看:135
本文介绍了从jQuery每个循环中删除item [i]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果物品到达时如何从物品中移除物品[i]:

How do I remove an item[i] from items once it reaches in:

$.each(items, function(i) {
    // how to remove this from items
});


推荐答案

如果要从数组中删除元素,请使用 splice()

If you want to remove an element from array, use splice()

var myArray =['a','b','c','d'];
var indexToRemove = 1;
// first argument below is the index to remove at, 
//second argument is num of elements to remove
myArray.splice(indexToRemove , 1);

myArray 现在将包含 ['a','c','d']

这篇关于从jQuery每个循环中删除item [i]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆