我可以将一个已经存在的 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.Afte...

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');
});

So to recap 2 already existing divs, need to place one of them into the other on click.

解决方案 html中在div中加背景图片

Using .appendTo()

$('#menu_form').on('click', function(){
   $('#form_div').appendTo('#display_div');  // appendTo -> selector
});

Using .append()

$('#menu_form').on('click', function(){
   $('#display_div').append( $('#form_div') ); // append -> object
});

阅读全文

相关推荐

最新文章