开发者

How to uncheck all checkboxes with a single radio button checking property using jQuery

开发者 https://www.devze.com 2023-03-15 07:27 出处:网络
I have a requirement to uncheck all checkboxes with single radio button.My HTML Code is <table> <tr><td><input type=\"checkbox\"></td><td><input type=\"checkbox

I have a requirement to uncheck all checkboxes with single radio button. My HTML Code is

  <table>
<tr><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
<tr><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
<tr><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
<tr><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
<tr><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
<tr><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
<tr><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
<tr><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
<tr><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
<tr><td><input type="checkbox"></td><td><input type="checkbox"></td><td><in开发者_开发知识库put type="checkbox"></td></tr>
</table>

My jQuery code is given below,Please correct the errors in it.

 $('TABLE TBODY TR').each(function()
  {
   $(this).children('td:eq(2)').append("<input type='radio' class=rad>");
  });
 $('TABLE TBODY TR').each(function()
   {
   $(this).find('input:radio').change(function()
   {
   if($(this).attr('checked'))
   {
       $(this).siblings(':checkbox').attr('checked',true);
            $(this).parents('tr').children('td').find('input:checkbox').not('$(this).siblings(':checkbox')').attr('checked',false);
   }
   });
   });
  $('TABLE TBODY TR').each(function()
  {
  $(this).find('input:checkbox').not('td:eq(2) :checkbox').change(function()
    {
    if($(this).attr('checked'))
    {
        $(this).parents('tr').children('td').find('input:checkbox').attr('checked',false);
        $(this).parents('tr').children('td').find('input:radio').attr('checked',false);

     }
    });
  });

Thank you :-)


How to uncheck all checkboxes with a single radio button checking property using jQuery?

This code will on radio change set the checkboxes to reflect its state.

$('#toggle').change(function() {
   $('#container :checkbox').prop('checked', this.checked);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消