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