2016-09-28 275 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); 
}); 

注:給人以事件和財產適當父設置