[jQuery] Re: insert div into group ordered by ID..

2009-02-18 Thread Kean
Just a suggestion, if you just need to sort the elements by id and displaying their order without modifying the DOM you can totally do this alert($('#group div').add('#delta').get().sort(function(a,b) {return a.id > b.id;})); On Feb 18, 12:15 pm, Ricardo Tomasi wrote: > I've since updated the

[jQuery] Re: insert div into group ordered by ID..

2009-02-18 Thread Ricardo Tomasi
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://jsbi

[jQuery] Re: insert div into group ordered by ID..

2008-12-22 Thread Michael Geary
I thought you wanted to insert the new element in order according to the *Greek* alphabet. That will take a bit of extra work. -Mike > From: Tbone > > Thanks to you, too, ksunBetween you and Ricardo, I think > I understand this now! > > On Dec 22, 11:42 am, ksun wrote: > > //locate the d

[jQuery] Re: insert div into group ordered by ID..

2008-12-22 Thread Tbone
Thanks to you, too, ksunBetween you and Ricardo, I think I understand this now! On Dec 22, 11:42 am, ksun wrote: > //locate the div before which you want to insert and then insert, > assuming they are ordered alphabetically >                 $('div[id]').each(function(){ >                  

[jQuery] Re: insert div into group ordered by ID..

2008-12-22 Thread Tbone
My expectation was an explanation, but many thanks for going the extra mile, Ricardo On Dec 22, 11:04 am, Ricardo Tomasi wrote: > I wrote a simple plug-in that will insert elements in alphabetical > order (by id) for you:http://ff6600.org/j/jquery.insertInOrder.js > > Use it like: > > > >

[jQuery] Re: insert div into group ordered by ID..

2008-12-22 Thread ksun
//locate the div before which you want to insert and then insert, assuming they are ordered alphabetically $('div[id]').each(function(){ if ($(this).attr('id') > 'delta') $(this).before(''); });

[jQuery] Re: insert div into group ordered by ID..

2008-12-22 Thread Ricardo Tomasi
I wrote a simple plug-in that will insert elements in alphabetical order (by id) for you: http://ff6600.org/j/jquery.insertInOrder.js Use it like: $('').insertInOrder('#group'); feel free to change the naming and alter the code :] cheers, - ricardo On Dec 22, 3:32 pm, Tbone <95dak...@g

[jQuery] Re: insert div into group ordered by ID..

2008-12-22 Thread Tbone
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 would go? Obviously between gamma and epsilon, but I need to search the ids for the first (id > "delta"). Then I can use your insert to p

[jQuery] Re: insert div into group ordered by ID..

2008-12-22 Thread ksun
try this, it will insert gamma1 before epsilon. $('#gamma~#epsilon').before(''); 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