我有两个下拉菜单:
<div class="btn-group">
<button type="button" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="pick-team">Team A</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item team-name" href="#">thunder</a>
<a class="dropdown-item team-name" href="#">cc</a>
<a class="dropdown-item team-name" href="#">testers</a>
</div>
</div>
<span class="badge badge-light">VS</span>
<div class="btn-group">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="pick-team">Team B</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item team-name" href="#">thunder</a>
<a class="dropdown-item team-name" href="#">cc</a>
<a class="dropdown-item team-name" href="#">testers</a>
</div>
</div>
&#13;
当一个人点击一个下拉项时,带有类选择团队的范围从默认团队a更改为团队b,并通过jquery使用以下代码设置值:
$(".team-name").click(function() {
var link = $(this).closest(":has(button .pick-team)").find('button .pick-team');
$(link).html($(this).text());
})
&#13;
问题在于,我有一个选择字段,将决定折腾赢家如何在用户选择两个团队后我将选项值和文本更改为选定的团队我不想把所有的选项中的团队名称,但只有两个用户选择了:
<div class="control-group">
<select name="toss">
<option>teamA</option>
<option>teamB</option>
</select>
</div>
&#13;