js实现点击验证码无刷新重新加载验证码图片

it2023-01-10  59

<html> <head></head> <body> <img id="verifyCode" onclick="reloadCode()" src="VerifyCodeServlet" /> </body> <script type="text/javascript"> function reloadCode(){ var verifyCodeNode = document.getElementById('verifyCode'); // 这里必须加入随机数,不然会被浏览器判定为同个请求,无法重新加载 verCodeNode.setAttribute('src', 'VerifyCodeServlet?' + Math.random()); } </script> </html>

 

最新回复(0)