ITPub博客

首页 > Linux操作系统 > Linux操作系统 > jQuery - remove select option based on text not value

jQuery - remove select option based on text not value

原创 Linux操作系统 作者:gavinlee 时间:2016-04-20 08:56:59 0 删除 编辑

you can use :contains to filter based on text content of an element, but note that it will return partial matches.
So :contains('Vaillant 835')will return :contains('Vaillant 835') and :contains('Vaillant 8356')

jQuery("#select_Boiler option:contains('Vaillant 835')").remove();

If you want to filter for equal you need to do a manual filter like

jQuery("#select_Boiler option").filter(function()
{     return $.trim($(this).text()) == 'Vaillant 835' }).remove();

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/310974/viewspace-2084463/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: svchost.exe CPU 过高
请登录后发表评论 登录
全部评论
  • 博文量
    51
  • 访问量
    795694