How do I remove a dropdown option using jQuery?

drop-down-menu, jquery

Solution

You can use `remove`:

$("#snackdropdown option[value='SnackName']").remove();

Where `#snackdropdown` is the name of your drop down list and 'SnackName' is the item you wish to remove.

Problem

I have a dropdown menu that is populated with snacks' names. the last option of the dropdown menu is for adding new snack and it works fine using jQuery. but all I want to know is if I can remove an option from dropdown menu. My imagination is like displaying a small delete icon in front of the option text on hovering on that option and be able to delete the option by clicking on it's delete button.

Original source