try this, it will insert gamma1 before epsilon. $('#gamma~#epsilon').before('<div id="gamma1"/>');
I first used after(), but that didn't work, looks like $ ('#gamma~#epsilon') selects #epsilon. On Dec 22, 10:48 am, Tbone <95dak...@gmail.com> wrote: > I'm a relative newbie with jQuery and have read the doc about DOM > manipulation but am too dense to answer this question: > > I have a series of DIVs in order by ID. I would like to insert a new > DIV into its proper place in the order... > > Given the following: > <div> > <div id="alpha"></div> > <div id="beta"></div> > <div id="gamma"></div> > <div id="epsilon"></div> > </div> > > How would I be able to insert the following div in its correct spot > (between gamma and epsilon)? > <div id="alpha"></div> > > Thanks in advance!