我想将每个选项移动到下一个选择,这是我目前所拥有的:
<form action="#" method="get">
<select multiple name="players" id="players">
<option value="player">player</option>
<option value="player1">player1</option>
<option value="player2">player2</option>
</select>
<select multiple name="team" id="teams">
<option value="team">team</option>
<option value="team1">team1</option>
<option value="team2">team2</option>
</select>
$('#players option').each(function() {
$(this).click(function() {
$(this).appendTo('#teams');
});
});
$('#teams option').each(function() {
$(this).click(function() {
$(this).appendTo('#players');
});
});
问题是当我点击已经附加的元素时,它只是不想移动到“原始”选择。如何解决?