开发者

jQuery if select option equals value remove value on second select

how could i do: if in #myselect1 volvo is selected then remove 1st(740) and 2nd(940) option in #myselectVolvo

<select id="myselect1">
  <opt开发者_运维问答ion value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

<select id="myselectVolvo">
  <option value="740">740</option>
  <option value="940">940</option>
  <option value="240">240</option>
  <option value="340">340</option>
</select>


$('#myselect1').change(function(){
  if($(this).val() == 'volvo'){ // or this.value == 'volvo'
    $('#myselectVolvo option:lt(2)').remove();
  }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜