如果我选择表格1

时间:2017-02-14 10:46:30

标签: javascript jquery

我有以下代码:

<select id="select1">
  <option value="1">1<option>
  <option value="2">2<option>
  <option value="3">3<option>
</select>
<select id="select2">
  <option value="one">one<option>
  <option value="two">two<option>
  <option value="three">three<option>
</select>

如果我选择<option>的任何选项,如何将<select id="select2">的所选<option value="one">更改为<select id="select1">

1 个答案:

答案 0 :(得分:0)

我希望以下代码可以帮助您

&#13;
&#13;
$(()=>{
  
  $('#select1').change(()=>{
       $('#select2').val('one');              
    });
  
  });
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="select1">

<option value="1">1<option>
<option value="2">2<option>
<option value="3">3<option>
</select>
<select id="select2">
<option value="one">one<option>

<option value="two">two<option>

<option value="three">three<option>

</select>
&#13;
&#13;
&#13;