<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<img src="img/1.jpg" " alt="" width="600px" height="400px">
<script>
function getRandom(N,M){
return Math.floor(Math.random() * (M-N+1))+N
}
const img = document.querySelector('img')
const random = getRandom(1,4)
img.src = `img/${random}.jpg`
</script>
</body>
</html>
刷新浏览器,图片自动切换-前端
最新推荐文章于 2024-07-16 17:18:30 发布