为什么这个reCaptcha javascript不工作?
问题描述:
见的jsfiddle应用https://jsfiddle.net/dciwill/m3psLpqm/5/为什么这个reCaptcha javascript不工作?
<head>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<scrypt type="text/javascript">
function recaptchaCallback() {
$('#submit1').attr('onclick="return ctypeY()"');
$('#submit2').attr('onclick="return ctypeN()"');
};
</script>
</head>
<body>
<table>
<tr>
<td align="center" colspan=4>
<input name="submit1" id="submit1" type=button class="subbutton" alt="Include EZPAY Processing Fees" value="Include EZPAY Processing Fees">
</td>
</tr>
<tr>
<td align="center" colspan="4" >
<input name="submit2" id="submit2" type=button alt="Exclude EZPAY Processing Fees" class="subbutton2" value="Exclude EZPAY Processing Fees">
</td>
</tr>
<tr>
<td align="center" colspan="4">
<div class="g-recaptcha" data-callback="recaptchaCallback" data-sitekey="6Lf0CiAUAAAAAH0PwOQd7QExyVQb3gx_8lTLtJ0x" align="center"></div>
</td>
</tr>
</table>
</body>
我想验证码验证后的属性添加到提交按钮。
答
感谢Mike McCaughan ...
function recaptchaCallback() {
$('#submit1').attr({onclick: "return ctypeY()"});
$('#submit2').attr({onclick: "return ctypeN()"});
};
@TyQ。不,[codereview.se]适用于有效的代码。请参阅https://codereview.meta.stackexchange.com/q/5777/13492。 –
@MikeMcCaughan对不起,我不熟悉StackExchange网站。我只听到人们在谈论它。认为这类问题与其他问题有关。 –
@请阅读[attr'](http://api.jquery.com/attr/#attr-attributeName- value)的文档以获取正确的语法。 –