当前位置:网站首页>JS picture switching (simple and practical)
JS picture switching (simple and practical)
2022-06-25 12:41:00 【Fall in love with*】
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
* {
margin: 0px;
padding: 0px;
}
#max {
margin: 100px auto;
width: 250px;
height: 350px;
border: 1px solid #F5DEB3;
background-color: #F5DEB3;
text-align: center;
}
div img {
margin: 15px 15px;
}
/* button{
margin-top:5px;
margin-left: 50px;
} */
</style>
</head>
<body>
<div id="max">
<h3 id="tips"></h3>
<img src="img/bear/1.jpg" id="img"><br>
<button id="previous" onclick="pre()"> Previous </button>
<button id="next" onclick="nex()"> Next </button>
</div>
<script type="text/javascript">
var a ;
var prev = document.getElementById("previous");
var next = document.getElementById("next");
var img = document.getElementsByTagName("img")[0];
var imgArr = ["img/bear/1.jpg", "img/bear/2.jpg","img/bear/3.jpg" , "img/bear/4.jpg","img/bear/5.jpg"];
var index = 0;
function pre(){
prev.onclick = function(){
index--;
if(index<0){
index=imgArr.length-1;
}
document.getElementById("img").src = imgArr[index];
// When you click the button Reset information
document.getElementById("tips").innerText = " Current "+(index+1)+" A picture ";
};
};
function nex(){
next.onclick = function(){
index++;
if(index>imgArr.length-1){
index=0;
}
document.getElementById("img").src = imgArr[index];
document.getElementById("tips").innerText = " Current "+(index+1)+" A picture ";
};
};
</script>
</body>
</html>
边栏推荐
- STM32 在flash中存储float数据
- PHP parsing QR code content
- Zhengzheng e-commerce source code -- Zhengzheng advertising e-commerce system development source code sharing
- Write regular isosceles triangle and inverse isosceles triangle with for loop in JS
- Does sklearex make your sklearn machine learning model training fly fast?
- C program linking SQLSERVER database: instance failed
- Penetration tool environment -- use of cknife Chinese kitchen knife
- el-select clear 清空内容时触发事件
- Explain AHP in human language (very detailed principle + simple tool implementation)
- GPS NMEA protocol, 0183 positioning data format dual mode positioning: gnxxx gps+bd full version
猜你喜欢
A commonly used statistical modeling method -- difference analysis
(2) Pyqt5 tutorial -- > using qtdesigner to separate interface code
High performance + million level Excel data import and export
(7) Pyqt5 tutorial -- > > window properties and basic controls (continuous update)
Go novice exploration road 1
Zhangxiaobai's road of penetration (IV) -- detailed explanation of XSS cross site script vulnerabilities
Zhangxiaobai's road of penetration (VI) -- the idea and process of SQL injection and the concat series functions and information of SQL_ Schema database explanation
冷启动的最优解决方案
ECSHOP commodity wholesale multi attribute multi specification multi inventory batch purchase ECSHOP wholesale plug-in ECSHOP multi attribute order
为何数据库也云原生了?
随机推荐
ECSHOP quickly purchases goods, simplifies the shopping process, and improves the user experience through one-step shopping
Upgrade opsenssh to 8.8p1
New and old cluster migration of Minio data
Fun pocket mall -- sharing the development source code of fun pocket app system
The push(), pop(), unshift(), shift() method in the JS array
Three jobs! You can learn this from me (attached with graduation vlog)
GPS receiver design (1)
(6) Pyqt5--- > window jump (registration login function)
Yunfan mall -- Yunfan mall system development source code sharing
PHP numeric array sorting and associative array sorting
Learning notes 2022 overview | automatic graph machine learning, describing AGML methods, libraries and directions
2022 meisai e topic ideas sharing + translation
PHP takes the difference set of two arrays
Huile optimization system -- sharing of secondary development source code of huile optimization app system
When MySQL queries fields in JSON format, it takes a property value of JSON data
2022 Baidu collection batch automatic push assistant
冷启动的最优解决方案
Service charge and time setting code sharing involved in crmeb withdrawal process
An example of using dynamic datalist
(5) Pyqt5 ---- another method of connecting signals and slots