Reputation: 719
My html code is
<select id="child[1]" name="child[1]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<select id="child[2]" name="child[2]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
My JS code not working
JS code is
alert(jQuery("#child").length);
Can you please help me how can I get the child array, I want to send the array through AJAX
Upvotes: 0
Views: 1054
Reputation: 119837
jQuery("select[name^=child]").serializeArray()
what this does is:
select
elements that have a name that starts with "child"the output is something like:
[
{name:'child[1]', value:'1'},
{name:'child[2]', value:'1'}
]
Upvotes: 0