javascript - Check all with specific value in checkbox using jquery -
i got problem when want develope checkall function using jquery.
i put checkboxes in table make clear , check checkbox value in input
.
for example, when click checkbox value type1
, checkboxes value including type1
checked (type1, type1-1 , type 1-2).
html:
<table> <tr class='type1'> <td><input type="checkbox" value="type1"></td> <td>type_1<td> </tr> <tr class='type1-1'> <td><input type="checkbox" value="type1-1"></td> <td>type_1-1<td> </tr> <tr class='type1-2'> <td><input type="checkbox" value="type1-2"></td> <td>type_1-2<td> </tr> <tr class='type2'> <td><input type="checkbox" value="type2"></td> <td>type_2<td> </tr> <tr class='type2-1'> <td><input type="checkbox" value="type2-1"></td> <td>type_2-1<td> </tr> </table>
is possible jquery?
thank you.
you can this:
$(':checkbox').change(function() { var chkvalue=$(this).attr("value"); if($(this).is(':checked')) { $(':checkbox[value*="'+chkvalue+'"]').prop('checked', true); //use selector^= or selector*= per need } else { $(':checkbox[value*="'+chkvalue+'"]').prop('checked', false); } });
Comments
Post a Comment