当前位置: 首页 > news >正文

两个多选框(select)之间值的左右上下移动

<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>两个多选框(select)之间值的左右上下移动</title>
</head>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script><script type="text/javascript">$(function () {$("#s1 option:first,#s2 option:first").attr("selected", true);$("#s1").dblclick(function () {var alloptions = $("#s1 option");var so = $("#s1 option:selected");if (so === null || so == "undefined") {return;}try {var a = (so.get(so.length - 1).index == alloptions.length - 1) ? so.prev().attr("selected", true) : so.next().attr("selected", true);} catch (e) {return;}$("#s2").append(so);});$("#s2").dblclick(function () {var alloptions = $("#s2 option");var so = $("#s2 option:selected");if (so === null || so == "undefined") {return;}try {var a = (so.get(so.length - 1).index == alloptions.length - 1) ? so.prev().attr("selected", true) : so.next().attr("selected", true);} catch (e) {return;}$("#s1").append(so);});$("#add").click(function () {var alloptions = $("#s1 option");var so = $("#s1 option:selected");var a = (so.get(so.length - 1).index == alloptions.length - 1) ? so.prev().attr("selected", true) : so.next().attr("selected", true);$("#s2").append(so);});$("#remove").click(function () {var alloptions = $("#s2 option");var so = $("#s2 option:selected");var a = (so.get(so.length - 1).index == alloptions.length - 1) ? so.prev().attr("selected", true) : so.next().attr("selected", true);$("#s1").append(so);});$("#addall").click(function () {$("#s2").append($("#s1 option").attr("selected", true));});$("#removeall").click(function () {$("#s1").append($("#s2 option").attr("selected", true));});$("#s1up").click(function () {var so = $("#s1 option:selected");if (so.get(0).index !== 0) {so.each(function () {$(this).prev().before($(this));});}});$("#s1down").click(function () {var alloptions = $("#s1 option");var so = $("#s1 option:selected");if (so.get(so.length - 1).index != alloptions.length - 1) {for (i = so.length - 1; i >= 0; i = 1 - 1) {var item = $(so.get(i));item.insertAfter(item.next());}}});$("#s2up").click(function () {var so = $("#s2 option:selected");if (so.get(0).index !== 0) {so.each(function () {$(this).prev().before($(this));});}});$("#s2down").click(function () {var alloptions = $("#s2 option");var so = $("#s2 option:selected");if (so.get(so.length - 1).index != alloptions.length - 1) {for (i = so.length - 1; i >= 0; i--) {var item = $(so.get(i));item.insertAfter(item.next());}}});});</script><table width="600" border="0" cellpadding="0" cellspacing="0"><tr><td width="100"><select name="s1" size="10" multiple="multiple" id="s1" style=" width:200px" ,style="height:300px;"><option value="opt01">option01</option><option value="opt02">option02</option><option value="opt03">option03</option><option value="opt04">option04</option><option value="opt05">option05</option><option value="opt06">option06</option><option value="opt07">option07</option><option value="opt08">option08</option><option value="opt09">option09</option><option value="opt10">option10</option></select></td><td width="37" align="center"><input type="button" name="addall" id="addall" value=">|"/><br/><input type="button" name="add" id="add" value=">>"/><br/><input type="button" name="remove" id="remove" value="<<"/><br/><input type="button" name="removeall" id="removeall" value="|<"/></td><td width="100"><select name="s2" size="10" multiple="multiple" id="s2" style=" width:200px height: 300px;"></select></td></tr>
</table></html>

 

http://www.lryc.cn/news/114866.html

相关文章:

  • 【设计模式】——模板模式
  • 工业机器视觉系统开发流程简介
  • 【Unity3D】Renderer Feature简介
  • 麻了!包含中科院TOP,共16本期刊被标记为“On Hold”状态!
  • 2.Flink应用
  • Matlab进阶绘图第25期—三维密度散点图
  • C++设计模式之桥接设计模式
  • 论文笔记:SUPERVISED CONTRASTIVE REGRESSION
  • Java 多线程并发 CAS 技术详解
  • 如何压缩高清PDF文件大小?将PDF文件压缩到最小的三个方法
  • 04 统计语言模型(n元语言模型)
  • Linux各目录详解
  • 【css】属性选择器分类
  • 备份容灾哪家好怎么样
  • 【前端实习生备战秋招】—HTML 和 CSS面试题总结(三)
  • Ansible Rsync 使用Ansible Rsync模块进行文件传输
  • Eclipse如何自动添加作者、日期等注释
  • uniapp返回
  • 【Antd】antd form表单的rules文案无法跟随状态重渲染的原因及解决办法
  • Rocketmq Filter 消息过滤(TAGS、SQL92)原理详解 源码解析
  • Attacks in NLP
  • 04-7_Qt 5.9 C++开发指南_QTreeWidget和QDockWidget
  • Keburnetes YAML配置文件管理
  • opencv基础-33 图像平滑处理-中值滤波cv2.medianBlur()
  • 后端进阶之路——深入理解Spring Security配置(二)
  • 怎么绘制汤姆索亚历险记思维导图?掌握这几个绘制步骤就可以
  • Redis和数据库更新先后顺序
  • JavaScript--AJAX
  • AI Chat 设计模式:13. 代理模式
  • 嵌入式开发实用工具——QFSViewer