用Jquery设置点击图片刷新验证码,但是只能点击一次,第二次就会失效,感觉是获取按钮对象的问题?
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>register</title><scrip...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>register</title>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
$(function () {
let date= new Date().getTime();
var img=document.getElementById("checkCode");
$("#checkCode").click(function () {
img.src="/day15/checkCodeServlet?"+date;
});
$("#change").click(function () {
img.src="/day15/checkCodeServlet?"+date;
});
});
</script>
</head>
<body>
<img id="checkCode" src="/day15/checkCodeServlet"/>
<a id="change" href="">看不清,换一张</a>
</body>
</html> 展开
<html lang="en">
<head>
<meta charset="UTF-8">
<title>register</title>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
$(function () {
let date= new Date().getTime();
var img=document.getElementById("checkCode");
$("#checkCode").click(function () {
img.src="/day15/checkCodeServlet?"+date;
});
$("#change").click(function () {
img.src="/day15/checkCodeServlet?"+date;
});
});
</script>
</head>
<body>
<img id="checkCode" src="/day15/checkCodeServlet"/>
<a id="change" href="">看不清,换一张</a>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询