I have not to find the appropriate result as my question. I want to get the checkboxes value by checkboxes class name in jQuery while clicking a button. If my button like:
<button id="ClickHere">Click Here</button>
And my check box like:
<input type="checkbox" name="skill_check[]" class="my-check-box" value="English"> <input type="checkbox" name="skill_check[]" class="my-check-box" value="Hindi"> <input type="checkbox" name="skill_check[]" class="my-check-box" value="Tamil">
Here how can I get all checkboxes values by class name on button click in jQuery?
You can get all checkboxes values by their class name on click in jQuery.
Apply this code
$('#ClickHere').on('click', function() { var val = []; $('.my-check-box:checked').each(function(i){ val[i] = $(this).val(); }); console.log(val); });
Output: {English, Hindi, Tamil}
Hope it will be helpful for you.
Question and answer is powered by AnsPress.io