如何复制< option>从一个< select>中选择到另一个?

编程入门 行业动态 更新时间:2024-10-26 15:30:21
本文介绍了如何复制< option>从一个< select>中选择到另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用这里的双面多选 www.stevefenton.co .uk/cmsfiles/assets/File/twosidemultiselect.html ,并且需要使用JQuery将右侧multiselect中的选定选项添加到另一个选择列表中.有人曾经做过此事,并且知道这样做的快速方法吗?

I am using the two sided multi select found here www.stevefenton.co.uk/cmsfiles/assets/File/twosidedmultiselect.html and need to add the selected options in the right hand multiselect to another select list with JQuery. Has anyone had to do this before and knows a quick way of doing this?

var selectedOptions = $("#myselect")[0].options;将获得这些选项,但是如何将这些选项写入另一个选择?

var selectedOptions = $("#myselect")[0].options; will get the options but how to write these to the other select?

推荐答案

var $options = $("#myselect > option").clone(); $('#secondSelectId').append($options);

实时演示

更多推荐

如何复制< option>从一个< select>中选择到另一个?

本文发布于:2023-10-31 01:54:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544642.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:lt   amp   option   select   gt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!