2016-09-28 218 views
-1

我有三个复选框。如果一个复选框被启用,我想禁用其他两个复选框。我如何使用JQuery和HTML来实现它?禁用复选框

我要实现它在MVC 4

Forenoon @Html.CheckBoxFor(x => x.FromDateforenoon, new { 
    style = "width:auto;", 
    id = "chkFromDate", 
    @onchange = "CalculatedaysOfLeave();" 
}) 
Afternoon @Html.CheckBoxFor(x => x.FromDateafternoon, new { 
    style = "width:auto;", 
    id = "chkAfternoon", 
    @onchange = "CalculatedaysOfLeave();" 
}) 
FullDay @Html.CheckBoxFor(x => x.FromDateFullDay, new { 
    style = "width:auto;", 
    id = "chkFullDay", 
    @onchange = "CalculatedaysOfLeave();" 
}) 
+0

感谢您对我想要做的javascript.How我可以实现answers.If? –

+0

Mussaib Siddiqui的答案是纯粹的JavaScript。但你用jquery lol标记了这个问题 – Luke

回答

0

的Jquery:

$("input[type=checkbox]").change(function() 
{ 
    $("input[type=checkbox]").prop('checked',false); 
    $(this).prop('checked',true); 
}); 

注:给人以事件和财产适当父设置