当前位置:网站首页>JS rotation chart
JS rotation chart
2022-07-27 08:17:00 【Little bee learns Java】
Shuffling figure 1
<style>
*{
margin:0;
padding: 0;
}
ul{
list-style: none;
}
#box{
position:relative;
width:632px;
margin: 100px auto;
}
#imgs{
width: 632px;
height:340px;
overflow:hidden;
}
#dots{
position:absolute;
left:530px;
bottom:15px;
width:100px;
}
#dots li{
float:left;
width:10px;
height:10px;
/* padding:5px; */
margin:0 3px;
border:2px solid #fff;
border-radius:50%;
}
</style>
<script>
window.onload = function(){
var oBox = document.getElementById('box');
var oImgs = document.getElementById('imgs');
var oDots = document.getElementById('dots');
var aIli = oImgs.getElementsByTagName('li');
var aDli = oDots.getElementsByTagName('li');
var num = 0;
var timer = null;
function change(n){
for(var i=0; i<aIli.length; i++){
// Hide all pictures
aIli[i].style.display = 'none';
// Remove all the small white circle background colors
aDli[i].style.background = '';
}
// Display the specified picture and small white circle background color according to the parameters in the following table
aIli[n].style.display = 'block';
aDli[n].style.background = '#fff';
}
// Automatically switch pictures
function setTimer(){
timer = setInterval(function(){
num++;
if(num == aIli.length){
num = 0}
// according to num Display the corresponding picture
change(num);
},2000);
}
setTimer();
// Hover the mouse to switch pictures , All the little white circles , Loop binding events
for(var i=0; i<aDli.length; i++){
// Because it is written directly in for In circulation , I don't know the number of floating circles , So we use self executing function
(function(i){
aDli[i].onmouseover = function(){
// Move the mouse into a small circle , Stop timer
clearInterval(timer);
// call change function , According to the first i A picture
change(i);
// If you need to make the automatic switching picture continue in the order before moving the mouse , Is set num The value of is i
num = i;
};
// The mouse leaves the small white circle , Reset timer
aDli[i].onmouseout = function(){
setTimer();
};
})(i);
}
};
</script>
</head>
<body>
<div id="box">
<ul id="imgs">
<li><img src="../04exercise/img/1.jpg" alt=""></li>
<li><img src="../04exercise/img/2.jpg" alt=""></li>
<li><img src="../04exercise/img/3.jpg" alt=""></li>
</ul>
<ul id="dots">
<li style="background:#fff"></li>
<li></li>
<li></li>
</ul>
</div>
</body>
边栏推荐
- 【uni-app高级实战】手把手带你学习一个纯实战复杂项目的开发1/100
- Vcenter7.0 installation of ibm3650m4 physical machine
- Idea remote debugging
- Vcenter7.0 managing esxi7.0 hosts
- STM32 small bug summary
- vCenter7.0管理Esxi7.0主机
- On data security
- 信息化项目风险控制与应用
- Containerd failed to pull private database image (kubelet)
- QT creator code style plug-in beautifier
猜你喜欢

All in one 1353 -- expression bracket matching (stack)

Five day travels to Beijing

Apache SSI remote command execution vulnerability

1024 | in the fourth year officially called Menon, the original intention is still there, and continue to move forward
![[applet] how to get wechat applet code upload key?](/img/b4/76e2f12269601c0a969a709ff8a397.png)
[applet] how to get wechat applet code upload key?

One book 1201 Fibonacci sequence

What is the real HTAP? (1) Background article

"PHP Basics" PHP statements and statement blocks
Why do major domestic manufacturers regard cloud computing as a pastry? Do you really understand this trillion market
![[MRCTF2020]Ezpop 1](/img/c0/41873fe5864490ade403eeddc26976.png)
[MRCTF2020]Ezpop 1
随机推荐
Teach you to build a nail warning robot hand in hand
Shell script learning day01
What are the software tuning methods? Let's see what Feiteng technology experts say about dragon lizard technology
SETTA 2020 国际学术会议即将召开,欢迎大家参加!
Shenzhi Kalan Temple
Prevent cookies from modifying ID to cheat login
All in one 1329 cells (breadth first search)
Alibaba cloud international receipt message introduction and configuration process
Idea remote debugging
Promise details
All in one 1353 -- expression bracket matching (stack)
Attack and defense world MFW
ERP生产作业控制 华夏
关于数据库的接口响应非常慢
How does kettle handle text data transfer as' 'instead of null
Netdata 性能监测工具介绍、安装、使用
Database startup report error_ user_ connect_ times &gt; 0 error
Lua iterator
regular expression
Harbor can't log in with the correct password