HTML checkbox - allow to check only one checkbox

前端 未结 5 1891
花落未央
花落未央 2021-01-19 14:07

I have some checkboxes in each row in my table. Each one checkbox has name=\'myName\' because I want to select only one checkbox in each row. But something I\'m

5条回答
  •  攒了一身酷
    2021-01-19 14:12

     $(function () {
         $('input[type=checkbox]').click(function () {
             var chks = document.getElementById('<%= chkRoleInTransaction.ClientID %>').getElementsByTagName('INPUT');
             for (i = 0; i < chks.length; i++) {
                chks[i].checked = false;
             }
             if (chks.length > 1)
                $(this)[0].checked = true;
         });
     });
    

提交回复
热议问题