Yes, you're quite right. I missed out the h3's initially, then added them back in without thinking! It should have been something like...
var cols = $('#dsViewport').find('div.column'); $('#dsViewport h3').each(function(){ // assuming you want the h3? var numPrecedingColumns = cols.index( $(this).next().get(0) ); // ..... do whatever ..... }); If you can have something other than a div.column following an h3 then you'll need to change the next(). On Dec 18, 5:19 pm, Chris <[EMAIL PROTECTED]> wrote: > On Dec 18, 12:05 pm, Wizzud <[EMAIL PROTECTED]> wrote: > > > var cols = $('#dsViewport').find('div.column'); > > $('#dsViewport h3').each(function(){ // assuming you want the h3? > > var numPrecedingColumns = > > cols.index( $('div.column:first', this)get(0) ); > > // ..... do whatever ..... > > }); > > Doesn't 'this' in the expression $('div.column:first', this) refer to > the current h3? Then the whole expression means, "Get me the > first .column in the context of the current h3," which, since the h3s > only contain text, is an empty array. Maybe there's a nuance I'm not > catching? > > Chris