我可以将一个已经存在的 div 附加到另一个已经存在的 div 上吗? [英] Can i append an already existing div to another already existing div?
本文介绍了我可以将一个已经存在的 div 附加到另一个已经存在的 div 上吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在自己的 div 中有一个联系表单,不透明度为 0,还有一个 div,其中的内容根据用户单击菜单的内容进行动态操作.在用户进入菜单的最后阶段后,我需要清除显示所有内容的 div 内容,然后将表单 div移动"到其中,像这样的工作吗?
I have a contact form in a div on it's own with opacity 0, and a div where content is dynamically manipulated depending on what the user click on the menu. After the user gets to the last stage of the menu i need to clear the content of the div that displays everything and then "move" the form div into it, would something like this work?
$('#menu_form').on('click', function() {
$('#form_div').append('#display_div');
});
所以要回顾 2 个已经存在的 div,需要在点击时将其中一个放到另一个中.
So to recap 2 already existing divs, need to place one of them into the other on click.
推荐答案
Using .appendTo()
$('#menu_form').on('click', function(){
$('#form_div').appendTo('#display_div'); // appendTo -> selector
});
使用 .append()
$('#menu_form').on('click', function(){
$('#display_div').append( $('#form_div') ); // append -> object
});
这篇关于我可以将一个已经存在的 div 附加到另一个已经存在的 div 上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文