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
2010-06-11 16:14:22
then use $(this) within the closure to access the "current" item in the loop.
amarsuperstar
2010-06-11 16:15:44
@amarsuperstar: was just in the process of adding that information :-)
Andy E
2010-06-11 16:17:13