将内容从一个隐藏的div移动到另一个显示的div [英] move content from one hidden div to another displayed div

查看:166
本文介绍了将内容从一个隐藏的div移动到另一个显示的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jquery将内容从一个隐藏的div移动到另一个显示的div?

how do i move content from one hidden div to another displayed div using jquery?

说我的显示样式的div1为none,另一个显示样式的div为"div2".

say i have div1 with display style is none and another div "div2" with display style block.

如何将内容从div1移至div2并清除div1?

how do I move the content from div1 to div2 and clear div1?

推荐答案

.contents()可能是您需要的:

$('#div1').contents().appendTo('#div2')

请注意,它将内部元素从一个div移动(而不是复制)到另一个div.

Take note that it will move (not copy) the inner elements from one div to the other.

这篇关于将内容从一个隐藏的div移动到另一个显示的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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