I tried to get value from class have defined values
<input type="checkbox" class="cat" value="3">
<input type="checkbox" class="cat" value="5">
<input type="checkbox" class="cat" value="8">
and my jquery code
$('.cat').click(function(){
var cat = Number($('.cat').val());
$(".cat").val(cat);
// after that using my code
}
Remove $(".cat").val(cat);
and use this
instead of '.cat' in selector
$('.cat').click(function(){
var cat = Number($(this).val());
// after that using my code
});
$(function(){
$('.cat').click(function(){
var cat = Number($(this).val());
console.log("cat value: " + cat);
// after that using my code
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="checkbox" class="cat" value="3">
<input type="checkbox" class="cat" value="5">
<input type="checkbox" class="cat" value="8">
its work but give to other checkbox sam value when I click on them
your code its working i think i have problam with code , thank you