<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>demo</title>
</head>
<body>
<div>
<img id="img" src="demo.php" alt="" onclick="this.src=this.src+'?'+Math.random()">
<a href="javascript;;" onclick="document.getElementById('img').onclick()">换一张?</a><br/>
</div>
</body>
</html>
demo.php为验证码的接口;
验证码封装地址:https://blog.csdn.net/weixin_42358094/article/details/89382330