Accessing key of an array on HTML check boxes
<p>I have a tree with checkboxes and their id has key for item and value as their value.</p>

<pre><code>&lt;input type="checkbox" name="list_code[4]" id="list_code[4]" value="AG12345678" checked="checked"&gt;
</code></pre>

<p>When users select a tree element I can access those by</p>

<pre><code>$('input[name^="list_code"]').each(function() {
    if ($(this).attr('checked')) 
        list_code = $(this).val();
});
</code></pre>

<p>I am able to get value <code>AG12345678</code> but I need to get key value too which is <code>4</code> from list_code[4] in this case. How can I access that value? </p>
