jQuery access each matched element from '.find' by an index

Posted by GHarping on Stack Overflow See other posts from Stack Overflow or by GHarping
Published on 2012-06-12T10:38:15Z Indexed on 2012/06/12 10:40 UTC
Read the original article Hit count: 205

Filed under:
|

Using jQuery's .find() method to return a set of elements, I am trying to access items in the returned set by their order in that set.

For example, a table with two rows and in each row a select box and two text input fields, accessed with the following:

$('table#tbl').find('tr.row').each(function(i)
{

});

To get the first element I would have thought I could use

$('table#tbl').find('tr.row').each(function(i)
{
    alert( $(this).find(':input').get(1).val() );
});

And variations of the above, but apparently this doesn't work. Could anyone suggest the correct method to access item x of n elements returned?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery