huacnlee / rucaptcha

Captcha Gem for Rails, which generates captcha image by Rust.
https://huacnlee.github.io/rucaptcha
MIT License
693 stars 133 forks source link

点击验证码怎么刷新呢?需要另写js或jquery吗 小白求教 #61

Closed liwenhang closed 6 years ago

liwenhang commented 6 years ago

$(".captcha-img").click(function(){ var timestamp = new Date().getTime(); $(this).attr('src',$(this).attr('src') + '?' +timestamp ); })

hjijin commented 6 years ago

$(this).attr('src',$(this).attr('src') + '?' +timestamp ); There is a problem,the timestamp will accumulate. this is ok: $(".rucaptcha-image").click(function(e){ var currentSrc = $(this).attr('src'); $(this).attr('src', currentSrc.split('?')[0] + '?' + (new Date()).getTime()); return false })