tags:

views:

83

answers:

1

I have a div and it has several input elements in it... I'd like to iterate through each of those elements. Ideas?

+1  A: 

Use children() and each(), you can optionally pass a selector to children

$('#mydiv').children('input').each(function () {
    alert($(this).text()); // "this" is the current element in the loop
});

You could also just use the immediate child selector:

$('#mydiv > input').each(function () { /* ... */ });
Andy E
then use $(this) within the closure to access the "current" item in the loop.
amarsuperstar
@amarsuperstar: was just in the process of adding that information :-)
Andy E