jQuery remove options from select

后端 未结 8 918
一生所求
一生所求 2020-11-28 02:58

I have a page with 5 selects that all have a class name \'ct\'. I need to remove the option with a value of \'X\' from each select while running an onclick event. My code is

8条回答
  •  感情败类
    2020-11-28 03:35

    find() takes a selector, not a value. This means you need to use it in the same way you would use the regular jQuery function ($('selector')).

    Therefore you need to do something like this:

    $(this).find('[value="X"]').remove();
    

    See the jQuery find docs.

提交回复
热议问题