I have a tree with checkboxes and their id has key for item and value as their value.
<input type="checkbox" name="list_code[4]" id="list_code[4]" value="AG12345678" checked="checked">
When users select a tree element I can access those by
$('input[name^="list_code"]').each(function() {
if ($(this).attr('checked'))
list_code = $(this).val();
});
I am able to get value AG12345678
but I need to get key value too which is 4
from list_code[4] in this case. How can I access that value?