<script>
function refreshcaptchacode(obj) {
console.log('this:', obj)
obj.setAttribute("src",
"https://jxetgglrfz.axzq.com.cn/cas/webpage/ppos_axzq/images/login/card2.png?date=" + new
Date());
}
$('#btn').click(function () {
console.log('img:', $('img'))
// refreshcaptchacode($('img')) // 报错
//
$('img').setAttribute('src','https://jxetgglrfz.axzq.com.cn/cas/webpage/ppos_axzq/images/logi
n/card2.png?date='+ new Date()) // 报错
// 方法一
//
$('#codeimg').attr('src','https://jxetgglrfz.axzq.com.cn/cas/webpage/ppos_axzq/images/login/c
ard2.png?date='+ new Date())
//
$('img').attr('src','https://jxetgglrfz.axzq.com.cn/cas/webpage/ppos_axzq/images/login/card2.
png?date='+ new Date())
// 方法二
//
$('#codeimg').prop('src','https://jxetgglrfz.axzq.com.cn/cas/webpage/ppos_axzq/images/login/c
ard2.png?date='+ new Date())
//
$('img').prop('src','https://jxetgglrfz.axzq.com.cn/cas/webpage/ppos_axzq/images/login/card2.
png?date='+ new Date())
// 方法三
// var imgLabel = document.getElementById('codeimg')
// imgLabel.src =
'https://jxetgglrfz.axzq.com.cn/cas/webpage/ppos_axzq/images/login/card2.png?date='+
Math.random()
// 方法四
// let a =
'https://jxetgglrfz.axzq.com.cn/cas/webpage/ppos_axzq/images/login/card2.png?date=' + new
Date()
// document.getElementById('codeimg').setAttribute('src', a)
// 方法五
refreshcaptchacode(document.getElementById('codeimg'))
})
</script>
</body>
</html>