I've since updated the script by request, it failed if you began with
a single element in the container. It now sorts by any attribute you
want (ids by default) and works with multiple elements both ways.

http://ff6600.org/j/jquery.insertInOrder.js

Examples at:
http://jsbin.com/itofi
http://jsbin.com/itofi/edit (source)

cheers,
- ricardo

On 22 dez 2008, 15:54, Tbone <95dak...@gmail.com> wrote:
> Thanks to you, too, ksun....Between you and Ricardo, I think I
> understand this now!
>
> On Dec 22, 11:42 am, ksun <kavi.sunda...@gmail.com> wrote:
>
> > //locate thedivbefore which you want toinsertand theninsert,
> > assuming they are ordered alphabetically
> >                 $('div[id]').each(function(){
> >                                 if ($(this).attr('id') > 'delta')
> >                                         $(this).before('<divid="delta"/>');
> >                 });
>
> > I think there is no selector that will do the same, but  I may be
> > wrong.
> > On Dec 22, 12:32 pm, Tbone <95dak...@gmail.com> wrote:
>
> > > Great! Thanks...
> > > However, I'm more clueless than I should be...and didn't pose the
> > > complete question...
>
> > > I have the divs as shown above, how do I locate where <div
> > > id="delta"></div> would go?
> > > Obviously between gamma and epsilon, but I need to search the ids for
> > > the first (id > "delta").  Then I can use yourinsertto properly
> > > place it.  I assume I use a selector, but am not sure how to put it
> > > together.
>
> > > On Dec 22, 10:25 am, ksun <kavi.sunda...@gmail.com> wrote:
>
> > > > try this, it willinsertgamma1 before epsilon.
>
> > > > $('#gamma~#epsilon').before('<divid="gamma1"/>');
>
> > > > I first used after(), but that didn't work, looks like $
> > > > ('#gamma~#epsilon') selects #epsilon.- Hide quoted text -
>
> > > - Show quoted text -

Reply via email to