Search code examples
jquerydrop-down-menuoptgroup

Remove select box value by optgroup


I have the multiple optgroups in selectbox and its some value are same, I want to remove particular optgroup values. How can i change below code to remove optgroup wise.

$("#selectBox option[value='option1']").remove();

Solution

  • In that case

    $('#select optgroup[label="popular"] option[value="1"]').remove()
    

    Demo: Fiddle