jQuery的选择删除选项 [英] jquery select remove option

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

问题描述

我目前正在成功使用它删除选项

I'm currently using this successfully to remove an option

    $("select#select_gender option[value='initial']").remove();

是否可以在不添加选择器的情况下删除选项-如下所示?

Is there a way remove an option without adding to the selector - like below?

    $('select#select_gender').val('initial').remove();

thx

推荐答案

$("select#select_gender option").filter("[value='initial']").remove();

我相信可以做到.

或根据您的最新评论:

var sel = $("select#select_gender");
sel.find("option[value='initial']").remove();

PS非常抱歉,进行了这么多(

PS sorry for so many edits :(

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

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