I'm trying to move a set of divs into their parent elements.
Currently I'm using: jQuery('.mydiv').each(function(){ jQuery(this).prependTo ('.mydivcontainer').remove(); }); this works somehow, but the problem is that all elements on the page with class .mydiv are inserted into each .mydivcontainer element. to avoid this, I tried prepending .mydiv to its parent; jQuery('.mydiv').each(function(){ jQuery(this).prependTo(jQuery (this).parent('.mydivcontainer')).remove(); }); but for some weird reason it doesn't work, .mydiv doesn't show up :( can anyone help me with this? thanks :D