I am having a set of checkboxes which allows multiple checking. And I want to get the values by the last selected one. for example consider 4 checkboxes with values 1, 2, 3, 4. If I select 4, 2, 1 i need the values [4,2,1] as I selected instead of getting [1,2,4]
this is my html code snippet
<li><input type="checkbox" class="checkGroup" value="1"></li>
<li><input type="checkbox" class="checkGroup" value="2"></li>
<li><input type="checkbox" class="checkGroup" value="3"></li>
<li><input type="checkbox" class="checkGroup" value="4"></li>
the code below is my JQuery script to get the values in a array
var arr = $.map($('.checkGroup:checked'), function(e, i) {
value = e.value;
return value;
});
Please help me to resolve this.
Aucun commentaire:
Enregistrer un commentaire