jQuery的从数组中删除元素 [英] Jquery remove element from array

查看:226
本文介绍了jQuery的从数组中删除元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该是有趣解决:)

This should be fun to solve :)

在文本字段我有值苹果,桃,香蕉

使用jQuery我创建从CSV数组。

Using Jquery I created an array from that CSV.

在HTML我有水果与相邻一个删除选项列表。当我点击删除我想从列表和文本字段中删除相应的水果。

In HTML I have a list of the fruits with a "remove" option next to each one. When I click "remove" I want to remove the corresponding fruit from the list and the text field.

我缺少一个功能将从数组中删除果实。我应该使用什么功能?

I'm missing one function that will remove fruits from the array. What function should I use?

http://jsfiddle.net/BXWqK/19/

推荐答案

您应该使用 JavaScript的接续

fruits_array.splice(fruit_index,1);

您也需要改变:

$('#果实)VAL(skills_array.join('')); $('#果实') .VAL(fruits_array.join(''));

这篇关于jQuery的从数组中删除元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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