复制代码 代码如下:
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.4.2.min.js"> <script type="text/javascript">
$(document).ready(function(){
// 把选择项追加给对方
$('#add').click(function(){
var options=$('#select1 option:selected');
var remove=options.remove();
remove.appendTo("#select2");
});
// 把所有项追加给对方
$('#addAll').click(function(){
var options=$('#select1 option');
var remove=options.remove();
remove.appendTo("#select2");
});
// 把选择项退回给对方
$('#remove').click(function(){
var options=$('#select2 option:selected');
var remove=options.remove();
remove.appendTo("#select1");
});
// 把全部项退回给对方
$('#removeAll').click(function(){
var options=$('#select2 option');
var remove=options.remove();
remove.appendTo("#select1");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="left">
<select multiple="multiple" id="select1" style="width:100px;height:160px">
<option>选项1</option>
<option>选项2</option>
<option>选项3</option>
<option>选项4</option>
<option>选项5</option>
</select>
</div>
<div>
<span id="add">选中项添加至右边>></span><br />
<span id="addAll">全部添加到右边>></span>
</div>
<div id="right">
<select multiple="multiple" id="select2" style="width:100px;height:160px"></select>
</div>
<div>
<span id="remove"><<选中项还原至左边</span><br />
<span id="removeAll"><<全部还原至左边</span>
</div>
</form>
</body>
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.4.2.min.js"> <script type="text/javascript">
$(document).ready(function(){
// 把选择项追加给对方
$('#add').click(function(){
var options=$('#select1 option:selected');
var remove=options.remove();
remove.appendTo("#select2");
});
// 把所有项追加给对方
$('#addAll').click(function(){
var options=$('#select1 option');
var remove=options.remove();
remove.appendTo("#select2");
});
// 把选择项退回给对方
$('#remove').click(function(){
var options=$('#select2 option:selected');
var remove=options.remove();
remove.appendTo("#select1");
});
// 把全部项退回给对方
$('#removeAll').click(function(){
var options=$('#select2 option');
var remove=options.remove();
remove.appendTo("#select1");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="left">
<select multiple="multiple" id="select1" style="width:100px;height:160px">
<option>选项1</option>
<option>选项2</option>
<option>选项3</option>
<option>选项4</option>
<option>选项5</option>
</select>
</div>
<div>
<span id="add">选中项添加至右边>></span><br />
<span id="addAll">全部添加到右边>></span>
</div>
<div id="right">
<select multiple="multiple" id="select2" style="width:100px;height:160px"></select>
</div>
<div>
<span id="remove"><<选中项还原至左边</span><br />
<span id="removeAll"><<全部还原至左边</span>
</div>
</form>
</body>
标签:
多选框,内容,交换
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“Jquery多选框互相内容交换的实例代码”评论...