Demo of reading selected checkbox values by using class and on change event


One
Two
Three
Four
Five

Check and uncheck the checkboxes to display selected checkbox values

JQuery

<script>
$(document).ready(function() {
$('input[type="checkbox"]').change(function(){
var str = '';
$.each($("input[type='checkbox']:checked"), function(){  
str = str + " " + ($(this).val());
});
$("#d1").html("Selected checkbox = " + str );
});
///////////
});
</script>

HTML

<input type=checkbox id='ckb1' value=One> One <br>
<input type=checkbox id='ckb2' value=Two> Two <br>
<input type=checkbox id='ckb3' value=Three> Three <br>
<input type=checkbox id='ckb4' value=Four> Four <br>
<input type=checkbox id='ckb5' value=Five> Five <br>
<button type='button' class='btn btn-secondary'  id=d1></button>