Hi Bittermonkey,
There is a great explanation with examples on jQuery documentation.
Please have a look at:
http://docs.jquery.com/Utilities/jQuery.each#objectcallback
Good luck
MaurĂcio
-----Mensagem Original-----
De: "bittermonkey" <brakes...@gmail.com>
Para: "jQuery (English)" <jquery-en@googlegroups.com>
Enviada em: segunda-feira, 2 de fevereiro de 2009 19:05
Assunto: [jQuery] Re: How do I get the index of the currently clicked
textbox?
Stephan, that was a good suggestion but I'm trying to minimize HTML
code because the page I am working on is asp.net. That's a useful
trick to know.
Mauricio it worked like a charm. Thank you so much. If you don't
mind, can you briefly explain why function(i) seems to know the
element's index?
On Feb 2, 3:08 pm, "Mauricio \(Maujor\) Samy Silva"
<css.mau...@gmail.com> wrote:
Try:
$('input[type=text]').each(function(i) {
$(this).click(function() {
alert(i);
});
});
MaurĂcio
-----Mensagem Original-----
De: "bittermonkey" <brakes...@gmail.com>
Para: "jQuery (English)" <jquery-en@googlegroups.com>
Enviada em: segunda-feira, 2 de fevereiro de 2009 17:47
Assunto: [jQuery] How do I get the index of the currently clicked textbox?
> Hi,
> How do I get the index of the currently clicked textbox? I have 5
> textboxes in a form, all of which I am binding a click event. Here is
> the code:
> $("#associate-form input[type=text]").bind("click", function()
> {
> alert(this); //what is its index position from the 5
> other textboxes?
> });
> Thanks in advance.