Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery move all children to another div

Tags:

jquery

I have a div with many childen. How do I move all of them to another div using jQuery?
my code looks like:

jQuery("body").append("<div id='popupWrapper'></div>");
var myID = $('.FloatingFrameLightBlue1').attr('id');
jQuery(myID).children().append("popupWrapper");

But it doesn't work. What I'm doing wrong?

like image 537
Luis LL Avatar asked Jul 17 '13 11:07

Luis LL


1 Answers

Here you have a very simple example of it: http://jsfiddle.net/LhR79/

As they have already told you. You need to use appendTo instead of append and specify the selector type (class, id... ) using the . or the # preceding the name. In your case: #popupWrapper as popupWrapper is an ID and not a class.

like image 150
Alvaro Avatar answered Oct 27 '22 20:10

Alvaro