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 .....
  });

You can tighten or loosen the selectors to fit your actual HTML model.

On Dec 18, 2:46 pm, pixeline <[EMAIL PROTECTED]> wrote:
> hello,
>
> i'm facing a complex traversing question, can you help?
>
> I need to know the number of a specific element with class="column"
> that are BEFORE my selected element.
>
> So, say i have this html (see below)  and i am in this selection:
>
> $('#dsViewport h3').each(function(index){
> ...
> $amountOfColumnsBefore = $(this).prev(".ds-column").length;
> $url = $(this).href("#"+$amountOfColumnsBefore);
>
> });
>
> My method does not work: $amountOfColumnsBefore = $(this).prevAll(".ds-
> column").length;
>
> Here is my html.
>
> <div class="dsViewport">
>      <div class="section">
>         <h3>2007</h3>
>           <div class="column">...</div>
>     </div>
>      <div class="section">
>         <h3>2006</h3>
>           <div class="column">...</div>
>           <div class="column">...</div>
>           <div class="column">...</div>
>     </div>
>      <div class="section">
>         <h3>2005</h3>
>           <div class="column">...</div>
>     </div>
>      <div class="section">
>         <h3>2004</h3>
>           <div class="column">...</div>
>          <div class="column">...</div>
>     </div>
> </div>
>
> Thanks for your help!
>
> Alexandre

Reply via email to