请注意,在这个示例中,我们假设 logo 和下载链接都已经准备好,并存储在一个数组中。在实际使用中,您需要根据您的需求修改这些数组,或者从服务器动态获取这些数据。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>随机更换 logo 和下载链接示例</title>
</head>
<body>
<h1>随机更换 logo 和下载链接示例</h1>
<div>
<img id="img1" src="" alt="logo">
<p>安卓:<a id="url1" href="" rel="external nofollow" rel="external nofollow" rel="external nofollow" >下载链接</a></p>
<p>苹果:<a id="url2" href="" rel="external nofollow" rel="external nofollow" rel="external nofollow" >下载链接</a></p>
<p>官网:<a id="url3" href="" rel="external nofollow" rel="external nofollow" rel="external nofollow" >下载链接</a></p>
</div>
<script>
// 定义 logo 和链接数组
const logos = [
'https://example.com/logo1.png',
'https://example.com/logo2.png',
'https://example.com/logo3.png'
];
const urls = [
['https://example.com/android1.apk', 'https://example.com/apple1.ipa', 'https://example.com/official1.exe'],
['https://example.com/android2.apk', 'https://example.com/apple2.ipa', 'https://example.com/official2.exe'],
['https://example.com/android3.apk', 'https://example.com/apple3.ipa', 'https://example.com/official3.exe']
];
// 随机选择 logo 和链接
const logoIndex = Math.floor(Math.random() * logos.length);
const urlIndex = Math.floor(Math.random() * urls.length);
// 更新页面内容
const logo = document.getElementById('img1');
const androidUrl = document.getElementById('url1');
const appleUrl = document.getElementById('url2');
const officialUrl = document.getElementById('url3');
logo.src = logos[logoIndex];
androidUrl.href = urls[urlIndex][0];
appleUrl.href = urls[urlIndex][1];
officialUrl.href = urls[urlIndex][2];
</script>
</body>
</html>
还没有评论呢,快来抢沙发~