I have a shorter and crazier way :) var divs = $('selector'); // [div1, div2] [].splice.call( divs, 1, 0, newdiv );// [div1, newdiv, div2]
Cheers Ariel Flesler On 10 ene, 17:52, "Josh Nathanson" <[EMAIL PROTECTED]> wrote: > Aha, the trick is to use the array notation directly as the jQuery argument. > That's what was tripping me up. > > Thanks Jonathan! > > -- Josh > > > > ----- Original Message ----- > From: Jonathan Sharp > To: jquery-en@googlegroups.com > Sent: Thursday, January 10, 2008 11:45 AM > Subject: [jQuery] Re: Inserting element into jQuery object > > Hi Josh, > > Most likely you'll have to create a new jQuery object. Take a look at the > slice method to grab your elements: > var divs = $('selector'); // [div1, div2] > var divs = $( [ divs.slice(0, 1), newdiv, divs.slice(1, 2) ] ); > // divs = [div1, newdiv, div2] > > Cheers, > -Jonathan > > On 1/10/08, Josh Nathanson <[EMAIL PROTECTED]> wrote: > > I'm having a devil of a time doing something that would seem to be pretty > basic. > > I have a jQuery object with two elements, and I want to insert a new > element > in between them - not altering the DOM, but just the jQuery object. > > So if my original jQuery object looks like this when logged in the > console: > [ div1, div2 ] > > I want it ultimately to look like this, inserting newdiv manually: > [ div1, newdiv, div2 ] > > ????? > > -- Josh- Ocultar texto de la cita - > > - Mostrar texto de la cita -