Remove item[i] from jQuery each loop

后端 未结 7 2002
别跟我提以往
别跟我提以往 2020-12-15 03:05

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

$.each(items, function(i) {
    // how to remove this from items
});
7条回答
  •  盖世英雄少女心
    2020-12-15 03:46

    I'm guessing you want $.map. You can return null to remove an item, and not worry about how indices might shift:

    items = $.map(items, function (item, index) {
        if (index < 10) return null; // Removes the first 10 elements;
        return item;
    });
    

提交回复
热议问题