1
我希望檢查/取消選中複選框,並使其啓用/禁用提交按鈕。 Javascript會觸發,不會顯示錯誤,但提交輸入不會多次切換。複選框啓用/禁用提交作品只有一次,jquery
JS:
$('#readTerms').change(function() {
var buttonsChecked = $('#readTerms:checked');
if (buttonsChecked.length)
{
$('#submitBusiness').removeAttr('disabled');
}
else
{
$('#submitBusiness').attr('disabled', 'disabled');
}
});
HTML:
<input type="checkbox" id="readTerms" name="agree"> <label for="agree">By checking the box you agree to the <a href="/terms" target="_blank">Terms & Conditions</a>.</label>
<input id="submitBusiness" class="btn positive iconCheck right" type="submit" name="create" value="Submit" disabled="disabled" />
提交按鈕開始禁用。點擊複選框並啓用它,再次點擊複選框,沒有任何東西。 if/else語句正常工作。代碼觸發,它在螢火蟲等行爲斷點等。
我在做什麼錯?
對我的作品;什麼瀏覽器,jQuery版本?嘗試'attr('disabled',true)' – ysth 2010-12-20 07:07:20