jQuery从下拉列表中删除一个选项,给定选项的文本/值 [英] jQuery to remove an option from drop down list, given option's text/value

查看:94
本文介绍了jQuery从下拉列表中删除一个选项,给定选项的文本/值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个下拉列表,并希望从该特定选项的文本/值中删除一个选项。是否可能使用jQuery?就像append一样,它为下拉列表添加了一个选项,是否有一个删除选项的功能?

I have a drop down list and would like to remove an option from it, given the text/value of that particular option. Is it possible using jQuery? Just like 'append' which adds an option to the drop down list, is there a function to remove an option?

我尝试搜索它,但我得到的都是例子下拉列表中的整个选项集都被删除,这不是我所寻求的。

I tried searching for it but all I got were examples where the entire set of options in the drop down list are removed, which is not what I seek.

欢呼

推荐答案

$(option [value ='foo'])remove();

或更好(如果您在页面中几个选择):

or better (if you have few selects in the page):

$(#select_id option [value ='foo'])。remove();

这篇关于jQuery从下拉列表中删除一个选项,给定选项的文本/值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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