如何复制< option>从一个< select>中选择到另一个? [英] How to copy <option> from one <select> to another?

查看:100
本文介绍了如何复制< option>从一个< select>中选择到另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using the two sided multi select found here http://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>中选择到另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆