1<!-- Find values of checked boxes with jquery -->
2<div class="fruit">
3 <label>
4 <span>Apple</span>
5 <input onchange="checkValues()" name="apple" type="checkbox" value="apple">
6 </label>
7
8 <label>
9 <span>Banana</span>
10 <input onchange="checkValues()" name="banana" type="checkbox" value="banana">
11 </label>
12
13 <label>
14 <span>Grape</span>
15 <input onchange="checkValues()" name="grape" type="checkbox" value="grape">
16 </label>
17</div>
18
19<script>
20 function checkValues() {
21 $('.fruit input:checkbox').each(function(index, element) {
22 if (element.checked === true) {
23 console.log(element.value)
24 }
25 });
26 }
27</script>
1//get multiple checkbox value in jquery
2
3$(document).ready(function(){
4$(".chk").click(function(){
5var d = $("input[name=test]"); if(d.is(":checked")){
6//
7}
8});
9});
10<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
11<input type="checkbox" name="test"> `test1`
12<input type="checkbox" name="test"> `test2`
13<input type="checkbox" name="test"> `test3`
14<input type="button" value="check" class='chk'/>