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
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();
}
}
精彩评论