Reputation: 15457
i have the following select element:
<select id='payTypes'>
<option value='1'>Cash</option>
<option value='2'>Check</option>
<option value='3'>Standard</option>
</select>
can someone show me how to remove the option Standard from the list
Upvotes: 2
Views: 227
Reputation: 8942
Use jQuery to get the payTypes select
and the eq selector to get the third (it's zero based so i use 2) and then use the remove method:
$("#payTypes option").eq(2).remove()
EDIT:
$("#payTypes option").each(function() {
if($(this).val() > 2) { //if it's not check or cash
$(this).remove();
}
}
Upvotes: 3