javascript - Jquery get each div's sub child divs and grab info into an array -


i have html looks 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 pull out each sub_main divs information array in javascript. far have jquery code

$('#main').find('.sub_main').each(            function() {                 alert('hi');            }); 

the alert test should show "hi" twice. not working. not clear on how can store 2 inputs in javascript array. great! thanks,

var array = $('#main input').map(function() {     return $(this).val(); }).get(); 

edit:

note return values of input elements under #main. can make $('#main input') selector specific need if not input elements desired.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -