<ul id="notDiv"> <li><b></b></li> <li><b></b></li> <li><b></b></li> <li><b></b><span id="moving">I am moving</span></li> <li><b></b></li> </ul>
If i am inserting into any <li>, regardless where my <span#moving> is in (ie. it can be in the third <li>, fifth <li> etc) var idx = 2; //place with other numbers $("#moving").insertAfter($("#moving").parent('#notDiv').find("li:nth- child("+idx+") b"); If i am inserting after the previous <li>, regardless where my <span#moving> is in (ie. it can be in the third <li>, fifth <li> etc) Does not account for first-child. $("#moving").insertAfter($("#moving").parent('li').prev().find('b')); Code is not tested. On Dec 20, 4:24 pm, Jack Finger <jack.fin...@gmail.com> wrote: > Hi, > I want to remove an object, but also move a piece of it into previous > HTML element, does exist something like ':prev' selector? Thanks! > My code: > > JS: > $('#to_move').insertAfter('#div > dl:previous(?) > dd'); > $('#div > dl:last').remove(); > > HTML: > <fieldset id="div"> > <dl> > <dd>...something...</dd> <!-- MOVE TO HERE --> > </dl> > <dl> > <dd>...something... <span id="to_move">TO MOVE</span></dd> > </dl> > </fieldset>