I'm trying to make a code that checks how many checkboxes are checked when clicking a button, as I'm making a system that duplicates records. I have a list with several checkboxes, and when the person clicks the "duplicate" button jQuery will check which ones are checked and get the value from them. I have no idea how to do it, because I tried in many ways and nothing. The last code I tried was this:
<script>
(document).ready(function(){
$("#duplicar-registro").on('click', function(){
var checkbox = $("#mcheckbox");
for(i=0;i<= checkbox.length;i++){
if($("input[id=mcheckbox]:checked") == true){
console.log(i); //Ver no console
}else{
console.log(i); //Ver no console também
}
}
})
});
</script>