当前位置:网站首页>JS learning notes 16: switching pictures small project practice
JS learning notes 16: switching pictures small project practice
2022-07-25 19:20:00 【The man fished alone in the cold river snow】
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> *{
margin: 0;
padding:0;
}
#outer{
width: 380px;
margin: 50px auto;
padding: 10px;
background-color: yellowgreen;
/* Center text */
text-align: center;
}
</style> <script> window.οnlοad=function(){
// Click the button to switch between pictures
// Get two buttons
var prev=document.getElementById("prev");
var next=document.getElementById("next");
var img=document.getElementsByTagName("img")[0];
// Create an array , The path to save the picture
var imgArr=["../../../ Picture material / JD.COM 1.jpg","../../../ Picture material / JD.COM 2.jpg","../../../ Picture material / JD.COM 3.jpg","../../../ Picture material /2.jpeg","../../../ Picture material /3.jpg"];
// Set prompt text obtain id by info Of p Elements
var info=document.getElementById("info");
// Set prompt text
info.innerHTML=" altogether "+imgArr.length+" A picture , Current "+(index+1)+" Zhang ";
// Create a variable , To save the index of the picture currently being displayed
var index=0;
prev.οnclick=function(){
// Switch to the previous , Index self subtraction
index--;
if (index<0){
index=0;
}
img.src=imgArr[index];
// When you click the button , Reset information
info.innerHTML=" altogether "+imgArr.length+" A picture , Current "+(index+1)+" Zhang ";
}; next.οnclick=function(){
// Switching pictures is to modify img Of src attribute // To modify the attributes of an element Elements . attribute = Property value if (index>imgArr.length-1){
index=0;
}
index++;
img.src=imgArr[index];
};
};
</script>
</head>
<body>
<div id="outer">
<p id="info"></p>
<img src="C:\Users\Administrator\Desktop\HTML\ Picture material \ JD.COM 1.jpg" alt=" JD.COM "><br>
<button id="prev">< Previous </button>
<button id="next"> Next > </button>
</div>
</body>
</html>
边栏推荐
- qt exec和show的区别
- Wechat campus maintenance application applet graduation design finished product of applet completion work (8) graduation design thesis template
- Pymoo学习 (8):Gradients
- Fruit chain "siege": it's a journey of sweetness and bitterness next to apples
- [Detr for 3D object detection] 3detr: an end to end transformer model for 3D object detection
- Pymoo learning (5): convergence analysis
- 乐理基础 调式
- [cloud native kubernetes] management of secret storage objects under kubernetes cluster
- Youfu network was invited to attend the 2022 national CIO conference and won the title of "CIO trusted brand"
- 房企打响“保交战”
猜你喜欢

小程序毕设作品之微信校园维修报修小程序毕业设计成品(5)任务书

小程序毕设作品之微信校园维修报修小程序毕业设计成品(1)开发概要

FPGA based 1080p 60Hz bt1120 interface debugging process record

Hongmeng - Damiao computing Sketchpad - Introduction

In the first half of the year, the shipment volume has exceeded that of the whole year of last year, and centritec millimeter wave radar has "captured" the international giant

【DETR用于3D目标检测】3DETR: An End-to-End Transformer Model for 3D Object Detection

Swift 基础 Codable(JSONEncoder JSONDecoder)的使用

CLIP还能做分割任务?哥廷根大学提出一个使用文本和图像prompt,能同时作三个分割任务的模型CLIPSeg,榨干CLIP能力...

基础乐理之音程的度数

Eve - 0day Threat Intelligence
随机推荐
The finished product of wechat campus maintenance and repair applet graduation design (1) development outline
leetcode刷题:动态规划07(不同的二叉搜索树)
[help center] provide your customers with the core options of self-service
李宏毅《机器学习》丨1. Introduction of this course(机器学习介绍)
【小程序开发】宿主环境详解
聚智云算,向新而生| 有孚网络“专有云”开启新纪元
PyQt5单击QTableView垂直表头verticalHeader获取行数据以及单击单元格获取行数据操作
Microsoft azure and Analysys jointly released the report "Enterprise Cloud native platform driven digital transformation"
小程序毕设作品之微信校园维修报修小程序毕业设计成品(2)小程序功能
【小程序开发】你了解小程序开发吗?
鸿蒙-大喵计算画板-视频
房地产行业大洗牌
【919. 完全二叉树插入器】
果链“围城”:傍上苹果,是一场甜蜜与苦楚交错的旅途
这种动态规划你见过吗——状态机动态规划之股票问题(上)
[Detr for 3D object detection] 3detr: an end to end transformer model for 3D object detection
聊聊接口性能优化的11个小技巧
“未来杯”第二届知识图谱锦标赛正式启动
【DETR用于3D目标检测】DETR3D: 3D Object Detection from Multi-view Images via 3D-to-2D Queries
Wechat campus maintenance and repair application applet graduation design finished product of applet completion work (6) opening defense ppt