开发者

remove options in my select element

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();
}
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜