我正在開發MVC應用程序。 我有複選框並提交按鈕。如何使用JQuery禁用按鈕?
我想在複選框的選中事件上啓用提交按鈕,在未選中的提交按鈕應該禁用。
如何做到這一點?
我有下面的代碼....
@model PaymentAdviceEntity.Account
@using PaymentAdviceEntity;
@{
ViewBag.Title = "Create";
PaymentAdvice oPA = new PaymentAdvice();
oPA = (PaymentAdvice)ViewBag.PaymentAdviceObject;
<div>
<input type="checkbox" class="optionChk" value="1" /> Paid
</div>
<input type="submit" value="Create" />
<input type="button" class="btn-primary" />
}
<script type="text/javascript">
$(".optionChk").on("change", function() {
if ($(this).is(":checked"))
{
alert("1");
$(".SubmitButton").attr("disabled", "disabled");
} else
{
alert("2");
$(".SubmitButton").attr("enable", "enable");
}
});
</script>
可能複製http://stackoverflow.com/questions/577548/how-can-i的 - 禁用jQuery中的對話框 - 從函數對話 – rhughes 2013-03-22 13:14:32