How can I disable other checkbox if I clicked one I..e dynamically created checkbox using input type=checkbox
@if (ViewBag.Products != null) { foreach (var item in ViewBag.Products) { <label class="PillList-item"> <input id="Check" type="CheckBox" name="@item.ProductID"/> <span class="PillList-label" > @item.Products <span class="Icon Icon--checkLight Icon--smallest"><i class="fa fa-check"></i></span> </span> </label> } }
Advertisement
Answer
Try to use the following code:
@section Scripts{ <script> $(document).ready(function () { $('input:checkbox').click(function () { $('input:checkbox').not(this).prop('checked', false); }); }); </script> }