【发布时间】:2018-02-09 05:34:17
【问题描述】:
我想在未选中 1 或两个复选框时禁用按钮,因此只有在选中两个复选框时才启用它。
复选框是在页面加载后添加的,所以我的代码目前如下所示:
jQuery(document).on('change','#voorwaarden', function() {
jQuery("#checkoutbtn").prop('disabled', !this.checked)
});
还有我的html:
<button type="submit" title="<?php echo $this->__('Place Order') ?>" disabled="disabled" class="button btn-checkout" id="checkoutbtn" onclick="review.save();"><span><?php echo $this->__('Place Order') ?></span></button>
<p><input type="checkbox" class="checkbox" id="voorwaarden" style="display:inline;" required/><b> Ik ga akkoord met de algemene voorwaarden <em>*</em></b></p>
<p><input type="checkbox" class="checkbox" id="geboorte" style="display:inline;"/><b> Ik ben ouder dan 18 jaar <em>*</em></b></p>
还有一个问题,我想在单击按钮和禁用按钮时显示警报,但我看到无法在禁用按钮上触发单击功能。
目前它只在点击#voorwaarden时启用按钮。
【问题讨论】:
标签: javascript jquery checkbox