And what is it you're trying to do exactly? I have to say I was caught curious by your subject 'Move element to parent div'. Where would an element be, if not inside its parent? Are you just trying to move it up to be the first child of the parent, by prependTo?
I wonder if in the first case, you're creating a bunch of clones, by a .prependTo(selector) with a selector that matches more than one element, then removing the original. And in the second case, you're moving the one element, then removing it. I haven't tested, but this is my best guess just looking at your code, and without seeing your html. - Richard On Tue, May 19, 2009 at 8:27 AM, Richard D. Worth <rdwo...@gmail.com> wrote: > What does your html look like? Is .mydivcontainer the immediate parent of > .mydiv? > > - Richard > > > On Tue, May 19, 2009 at 7:20 AM, aly <he...@digitalnature.ro> wrote: > >> >> >> 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 >> > >