我对此代码存在一些问题:
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$( "#continue" ).click(function() {
var c = $('[name="recaptcha_challenge_field"]').attr('name');
var r = $('[name="recaptcha_response_field"]').attr('name');
alert( "c=" + c );
alert( "r=" + r );
});
});
</script>
单击标识为continue
的按钮时,警报框不会显示。我的代码有问题吗?
答案 0 :(得分:3)
您没有用于文档就绪的结束函数包装器。所以它应该是:
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$( "#continue" ).click(function() {
var c = $('[name="recaptcha_challenge_field"]').attr('name');
var r = $('[name="recaptcha_response_field"]').attr('name');
alert( "c=" + c );
alert( "r=" + r );
});
});
答案 1 :(得分:1)
你错过了一个clossing })
:
$(document).ready(function(){
$( "#continue" ).click(function() {
var c = $('[name="recaptcha_challenge_field"]').attr('name');
var r = $('[name="recaptcha_response_field"]').attr('name');
alert( "c=" + c );
alert( "r=" + r );
});
}); // <<<<<==== THIS IS MISSING