Monday, 22 August 2022

Use of .map in jQuery to get selected checkboxes values:

HTML:
<input type="checkbox" class="chkitem" value="1"/>
<input type="checkboxclass="chkitem" value="2"/>
<input type="checkboxclass="chkitem" value="3"/>

jQuery:
var ids = $(".chkitem:checked").map(function () {
                        return $(this).val();
                    }).get();

No comments:

Post a Comment