我想防止结帐按钮工作,直到检查复选框。他们可以在不单击条款和条件的情况下结帐,复选框
<!--Beginning jQuery !-->
<script type="text/javascript">
jQuery(window).load(function(){
jQuery('#checkoutButton').unbind('click');
jQuery("#checkoutButton").click(function(event)
jQuery('#checkoutButtonDup').unbind('click');
jQuery("#checkoutButtonDup").click(function(event)
{
event.preventDefault();
if (jQuery("#TermsandConditions").val() == ""){
alert("Please check Terms of Use checkbox");
return false;
} else {
Infusion.ManageCart.submitForm('oneStepCheckout', true, 0, 0);
return true;
}
});
});
</script>
<!--End of jQuery!-->
<!--Beginning of checkbox TermsandConditions!-->
<div>
<input type="checkbox" id="TermsandConditions" name="TermsandConditions"/>
<label for="TermsandConditions" class='ff-label' style='display:inline; color:#990000'><strong>I have read and agree to the Terms of Use.</strong></label>
</div>
<!--End of checkbox TermsandConditions!-->
您是否在寻找。
jQuery的.is()
和:checked
可以使其真正简单
这是演示小提琴演示
这是一个jsfiddle,可以删除残疾人属性。如果您想根据复选框状态在按钮上禁用/删除禁用:
,则可以扩展此信息:$(function(){
$("#cb").on('click',function(){
if($(this).is(':checked')){
$("#btn").removeAttr("disabled");
}
})
});