jquery的综合应用2(select里option元素的移动)
下面演示了两个下拉框元素的移动
<script type="text/javascript">
//<input name="add" id="add" type="button" class="button" value="-->" />
$("#add").click(function(){
$("#first option:selected").appendTo($("#second"));
});
//<input name="add_all" id="add_all" type="button" class="button" value="==>" />
$("#add_all").click(function(){
$("#first option").appendTo($("#second"));
});
//<input name="remove" id="remove" type="button" class="button" value="<--" />
$("#remove").click(function(){
$("#second option:selected").appendTo($("#first"));
});
//<input name="remove_all" id="remove_all" type="button" class="button" value="<==" />
$("#remove_all").click(function(){
$("#second option").appendTo($("#first"));
});
//双击
$("#first").dblclick(function(){
$("#first option:selected").appendTo($("#second"));
});
$("#second").dblclick(function(){
$("#second option:selected").appendTo($("#first"));
});
</script>