i have issue about when i search data all checkbox will checked. i want is when i search data . Then data showed must be checked.
example i search the word "vin". only the word have vin must checked/true
this is my html
<input />
<table >
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</table>
<table class="AvailableGroupLab availGrpLabs avalLabs">
<tr>
<td><input type='checkbox'/></td>
<td><span>wewe</span>
</td>
<td>16</td>
</tr>
<tr>
<td><input type='checkbox' /></td>
<td><span>Melvin</span>
</td>
<td>18</td>
</tr>
<tr>
<td><input type='checkbox' /></td>
<td><span>Marvin</span>
</td>
<td>20</td>
</tr>
</table>
this is my script
function filter(element) {
var $trs = $('.AvailableGroupLab tr').hide();
var regexp = new RegExp($(element).val(), 'i');
var $valid = $trs.filter(function () {
return regexp.test($(this).children(':nth-child(2)').text())
}).show();
$valid.find(':input:checkbox').attr("checked",true);
$trs.not($valid).hide()
}
$('input:text').on('keyup change', function () {
filter(this);
})