I have checkboxes with HTML:
<input type="checkbox" class="selectMakeup" name="needsPartNumber">
There can be a lot of checkboxes with the same class. I want to loop through each of the checked checkboxes.
$('.selectMakeup').each(function() {
console.log($(this).html())
console.log($(this).prop('checked'))
if ($(this).prop('checked')) {
//Do Stuff
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="checkbox" class="selectMakeup" name="needsPartNumber">
console.log($(this).html())
returns
<input type="checkbox" name="needsPartNumber">
But console.log($(this).prop('checked'))
returns undefined
.