0
我试着在Google上进行研究,并在这里浏览了一些问题。我尝试了一些解决方案,但我无法让他们工作。使用jQuery问题进行验证码刷新
<td>
<img id="captcha" src="captcha.php" name="captcha" />
<img src="refresh.jpg" width="25" alt="" id="refresh_captcha" name="refresh_captcha" />
<input type="text" name="txtCaptcha" id="txtCaptcha" size="10" />
</td>
下面的代码不起作用:
$('.refresh_captcha').click(function(){
$('img').attr('src', 'captcha.php?cache=' + new Date().getTime());
});
我也试过这样:
$("#refresh_captcha").click(function() {
$("#captcha").attr("src","captcha.php?r=" + Math.random());
});
而这也:
jQuery(function($) {
jQuery('#captcha').after("<a href=\"#\" id=\"refresh_captcha\">Refresh<\/a>");
jQuery('body').delegate('#refresh_captcha','click',function(){
jQuery.ajax({
'success':function(html){
jQuery("#captcha").attr("src",html)
},
'url':'/captcha.php?refresh=1',
'cache':false
});
return false;
});
});
任何人都可以帮助我?
有什么问题?什么是“不工作”? – corroded 2011-06-11 06:09:06
工作不意味着验证码不会刷新 – user236501 2011-06-11 06:10:33
'$(“ refresh_captcha”)'将无法工作,因为没有与类名'refresh_captcha'但第二个应该够没有元素。你看到'r'的值每次点击都随机化了吗? – tradyblix 2011-06-11 06:16:00