deviloper
deviloper

Reputation: 7240

How do I remove a dropdown option using jQuery?

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.

Upvotes: 3

Views: 22604

Answers (1)

Darren
Darren

Reputation: 70786

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.

Upvotes: 6

Related Questions