Get value of selected checkbox jQuery

    <th><input type="checkbox" id="selectAll"></th>
     <td><input type="checkbox" class="id" value="{{ $d->id }}" name="ids" ></td>
     <td><input type="checkbox" class="id" value="{{ $d->id }}" name="ids" ></td>
     <td><input type="checkbox" class="id" value="{{ $d->id }}" name="ids" ></td>
     <td><input type="checkbox" class="id" value="{{ $d->id }}" name="ids" ></td>
     <td><input type="checkbox" class="id" value="{{ $d->id }}" name="ids" ></td>
$(document).ready(function() {
$("#selectAll").click(function(){

if( $(this).prop("checked")) {
              $(".id").prop("checked", false);
          } else {
              $(".id").prop("checked", true);
          }  

          console.log($('input[name="ids"]:checked').serialize());

//OR


          $('input[name="ids"]:checked').each(function() {
   console.log(this.value);
});

});
});

Leave a Reply