软件工程web课程第一次实验作业
开头总结
本次作业使用html+css+js实现了一个简单页面
最终我要记录的是使用js完成了轮播图中图片背景的转换
<script>
window.onload = function () {
const logo = document.getElementById('logo');
logo.onclick = function () {
window.location.href = "open.html";
}
const bac_img = document.getElementById('banner');
const rig = document.getElementById('rig');
const le = document.getElementById('le');
let index = 1;
le.onclick = function () {
index=index-1;
if(index===0){
index=5;
}
let imag_url='./images/zzf'+index+'.jpg';
bac_img.style.backgroundImage = 'url('+imag_url+')';
}
rig.onclick=function (){
index=index+1;
if(index===6){
index=1;
}
let imag_url='./images/zzf'+index+'.jpg';
bac_img.style.backgroundImage = 'url('+imag_url+')';
}
}
</script>

浙公网安备 33010602011771号