Reputation: 2134
I am having a problem removing an option from my drop down list. It does nothing when I load the page any ideas? I am using .remove()
but this is doing nothing.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<title>Test</title>
<script>
$(document).ready(function () {
$("#bytype option[value='foo']").remove();
});
</script>
</head>
<body>
<select name="bytype" id="bytype">
<option value="foo">foo</option>
<option value="Boo">Boo</option>
<option value="Coo">Coo</option>
</select>
</body>
</html>
Upvotes: 1
Views: 1470
Reputation: 1311
Use this instead. Replace 'Your value'
with the value of foo
.
$("#Select ID").removeOption("Your Value");
Upvotes: 1
Reputation: 69973
$("#bytpe option[value='foo']").remove();
You spelled your ID wrong. You're missing the second y.
Upvotes: 0
Reputation: 60448
Spelling mistake its not bytpe
it is bytype
$("#bytype > option[value='foo']").remove();
Upvotes: 0