You need to give the class .bt some context other than the whole
document ...

$('.botoes').each(function(){
        alert( $('a', this ).index( $( '.bt', this )[0] ) );
});


On Oct 11, 4:34 pm, ecopantoche <[EMAIL PROTECTED]> wrote:
> hello all,
>
> I'm new to jQuery, and have the following need:
>
> 01. I have some divs with the same class, and inside of each, I have
> two <a>, from which one will have a class "bt" and the other no class
> (this is done via the user interaction)
>
> 02. the issue here is that I need to get the index of which <a> has
> the class in each <div>...
>
> I've tried the following js, but it just tells me the index for the
> first one, the second one gives me a "-1" (but as you can see, it is
> there!)
>
> the js:
>
> $(".botoes").each(function(){
>         alert($("a", $(this)).index($('.bt')[0]))
>
> });
>
> the html:
>
> <div class="botoes">
> <a href="#" class="bt">teste</a>
> <a href="#">teste2</a>
> </div>
> <div class="botoes">
> <a href="#">teste</a>
> <a href="#" class="bt">teste2</a>
> </div>
>
> help please! (is there any other way to do this?)

Reply via email to