0

我正在使用 easydropdown ( https://github.com/patrickkunka/easydropdown ) 来设置我的选择下拉字段的样式。

到目前为止,一切都很好。

然而,当试图使 2 个选择框可靠时,第 2 个框仍保留初始值。我尝试了 jsfiddle,jet 似乎无法正确添加资源:示例:

http://jsfiddle.net/49FK9/46/

<script type='text/javascript' src="https://cdn.jsdelivr.net/jquery.easydropdown/2.1.4/jquery.easydropdown.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/jquery.easydropdown/2.1.4/themes/easydropdown.css">
<select name="test1" class="dropdown" id="test1">
      <option value="0">Select</option>
      <option value="1">Value 1</option>
      <option value="2">Value 2</option>
    </select>
    <select name="test2" class="dropdown" id="test2">
      <option value="0">Select</option>
      <option value="1">Value 1</option>
      <option value="2">Value 2</option>
    </select>

    <script type='text/javascript'>document.getElementById('test1').addEventListener("change", function() {
  document.getElementById('test2').selectedIndex = document.getElementById('test1').selectedIndex;
}, false);</script>

我会很感激任何帮助。

4

2 回答 2

0
<script type='text/javascript' src="https://cdn.jsdelivr.net/jquery.easydropdown/2.1.4/jquery.easydropdown.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/jquery.easydropdown/2.1.4/themes/easydropdown.css">
<select name="test1" class="dropdown" id="test1">
      <option value="0">Select</option>
      <option value="1">Value 1</option>
      <option value="2">Value 2</option>
    </select>
    <select name="test2" class="dropdown" id="test2">
      <option value="0">Select</option>
      <option value="1">Value 1</option>
      <option value="2">Value 2</option>
    </select>
<script type='text/javascript'>
    document.getElementById('test1').addEventListener("change", function() {
  document.getElementById('test2').selectedIndex = document.getElementById('test1').selectedIndex;
}, false);
</script>
于 2016-07-26T20:05:43.800 回答
0

设法让它工作,但使用引导选择而不是easydropdown。

$('.selectpicker').selectpicker('refresh'); 做的工作

于 2016-08-03T08:48:27.553 回答