Jquery get each div's sub child divs and grab info into an array
Posted
by McNabbToSkins
on Stack Overflow
See other posts from Stack Overflow
or by McNabbToSkins
Published on 2010-04-27T15:33:02Z
Indexed on
2010/04/27
15:33 UTC
Read the original article
Hit count: 365
jQuery
|JavaScript
I have a some html that looks like this
<div id="main">
<div id="sub_main_1" class="sub_main">
<input type="text" class="sub_name_first" /><br />
<input type="text" class="sub_name_second" /><br />
</div>
<div id="sub_main_2" class="sub_main">
<input type="text" class="sub_name_first" /><br />
<input type="text" class="sub_name_second" /><br />
</div>
</div>
I would like to pull out each sub_main divs information into an array in javascript. So far I have this as my jquery code
$('#main').find('.sub_main').each(
function() {
alert('hi');
});
The alert is just a test that it should show "hi" twice. But this is not working. I am also not clear on how I can store the two inputs in a javascript array. Any help would be great! Thanks,
© Stack Overflow or respective owner