您好我正在尝试将所选项目从一个多个组合框传递到另一个多组合框。
我该怎么做?那有什么例子吗?
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<SELECT NAME="possible" SIZE"10" MULTIPLE>
<OPTION VALUE="New Red Corvette">New Red Corvette</OPTION>
<OPTION VALUE="Vintage Red Corvette">Vintage Red Corvette</OPTION>
<OPTION VALUE="Old Red Corvette">Old Red Corvette</OPTION>
</SELECT>
<SELECT NAME="wishlist" SIZE="10" MULTIPLE>
<OPTION VALUE="Old Red Jalopy">Old Red Jalopy</OPTION>
</SELECT>
<INPUT TYPE="BUTTON" VALUE="Add to wishlist"
ONCLICK="MyMoveItem(possible,wishlist);">
<INPUT TYPE="BUTTON" VALUE="Remove from wishlist"
ONCLICK="MyMoveItem(wishlist,possible);">
</BODY>
</HTML>
答案 0 :(得分:1)
$("#b1").click(function(){
$("#s2").append( $("#s1 option:selected"))
})
$("#b2").click(function(){
$("#s1").append( $("#s2 option:selected"))
})
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<SELECT id="s1" NAME="possible" SIZE"10" MULTIPLE>
<OPTION VALUE="New Red Corvette">New Red Corvette</OPTION>
<OPTION VALUE="Vintage Red Corvette">Vintage Red Corvette</OPTION>
<OPTION VALUE="Old Red Corvette">Old Red Corvette</OPTION>
</SELECT>
<SELECT id="s2" NAME="wishlist" SIZE="10" MULTIPLE>
<OPTION VALUE="Old Red Jalopy">Old Red Jalopy</OPTION>
</SELECT>
<INPUT TYPE="BUTTON" id="b1" VALUE="Add to wishlist"
ONCLICK="MyMoveItem(possible,wishlist);">
<INPUT TYPE="BUTTON" id="b2" VALUE="Remove from wishlist"
ONCLICK="MyMoveItem(wishlist,possible);">
&#13;