-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
  • 12,566
  • 16
  • 32
  • 51
Jason
  • 403
  • 1
  • 6
  • 14

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
  • 197
  • 5