Link to home
Start Free TrialLog in
Avatar of vbnetcoder

asked on

Remove element from a dropdown in jquery

How do i remove an item programmatically from a drop down list in jquery?

Specifically, I want to remove an item where the value is "N". How would i do so...

This is how they are being added:

Avatar of Jon Norman
Jon Norman
Flag of United Kingdom of Great Britain and Northern Ireland image

$dd.find("option [value=\"N\"]").remove();
Avatar of soupBoy
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Sorry, I walked away from my computer and then completed my post.  Didn't mean to make it look like I was copying your post!

Just curious, why are you escaping the quotes?  I haven't done that before....

Avatar of vbnetcoder


This syntax posted by soupBoy worked:

Hi Chris,

option[value="N"] is just a string, if you delimit the string with single quotes then you can use 'option[value="N"]', if you delimit the string with double quotes you need to excape the double quotes inside the string "option[value=\"N\"]" -