简易轮播图

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Title</title>

<link rel="stylesheet" href="../css/common.css">

</head>

<body>

<!--轮播图-->

<div class="justify-content-center" >

<div id="slideshow" >

<img id="SlideshowOne" src="../img/banner_03_1y5v.jpg" alt="">

<div class="justify-content-center OptionButton" >

<div id="OptionButtonOne"></div>

<div id="OptionButtonTwo"></div>

</div>

</div>

</div>

</body>

</html>

<style>

#slideshow{

position: relative;

}

#OptionButtonOne,#OptionButtonTwo{

width: 10px;

height: 10px;

margin: 5px;

border-radius: 50%;

cursor: pointer;

background: white;

}

#slideshow>img{

width: 1000px;

height: 350px;

}

.OptionButton{

position: absolute;

z-index: 5;

top: 300px;

left: 500px;

}

</style>

<!--<script src="../js/slideshow.js"></script>-->

<script>

var img = document.getElementById("SlideshowOne");

var slideshow = document.getElementById("slideshow");

var OptionButtonOne = document.getElementById("OptionButtonOne");

var OptionButtonTwo = document.getElementById("OptionButtonTwo");

var index = 1;

var timer;

window.onload = function () {

function lunbo(){

//获取img对象

if (index == 1){

img.src = "../img/banna_03_fd4q.jpg";

index=0;

// alert(index)

}else{

img.src = "../img/banner_03_1y5v.jpg";

index = 1;

}

}

//2.定义定时器

timer = setInterval(lunbo,2000);

slideshow.onmouseover = function (){

// alert("onmouseover我进来了");

clearInterval(timer);

}

slideshow.onmouseout = function (){

// alert("onmouseout我进来了");

//2.定义定时器

timer = setInterval(lunbo,2000);

}

OptionButtonOne.onmouseover = function (){

// alert("onmouseover我进来了");

img.src = "../img/banner_03_1y5v.jpg";

OptionButtonOne.style.background="red";

OptionButtonTwo.style.background="white";

// clearInterval(timer);

}

OptionButtonTwo.onmouseover = function (){

// alert("onmouseover我进来了");

img.src = "../img/banna_03_fd4q.jpg";

OptionButtonOne.style.background="white";

OptionButtonTwo.style.background="red";

// clearInterval(timer);

}

}

</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值