-1

Having two checkboxes and both having different values when I select checkbox with value 10000 in console I am always getting value 1000

HTML

<input type="checkbox" name="group2[]" class="ci_check" value="1000" />1000
<input type="checkbox" name="group2[]" class="ci_check" value="10000" />10000

jQuery

$(".ci_check").click(function(){
    if ($('.ci_check').is(":checked")) {
        var abc = $("input[type='checkbox']").val();
        console.log(abc);
    }
});
Nguyễn Văn Phong
  • 13,506
  • 17
  • 39
  • 56
Jason
  • 415
  • 1
  • 6
  • 16

1 Answers1

2

Because you don't select clicked element. Try this:

$(".ci_check").click(function(){
    if ($(this).is(":checked")) {
        var abc = $(this).val();
        console.log(abc);
    }
});
Grey Chanel
  • 212
  • 1
  • 5