To set a checkbox checked with a certain value we use a function prop() with the attribute selector.
$('selector').prop('checked', true);
For example:
<input class="chkbox" name="ex[]" type="checkbox" value="0">0
<input class="chkbox" name="ex[]" type="checkbox" value="1">1
Suppose we want to set checkbox true where value is equal to 1 with jquery. For this, we will add the following script:
$('input.chkbox[value="1"]').prop('checked', true);
0 Comment(s)