This article shares the specific code of js to achieve the effect of the carousel map for your reference. The specific content is as follows 1. HTML part <div id="box"> <ul> <li class="show"><img src="img/1.jpg" alt=""></li> <li><img src="img/2.jpg" alt=""></li> <li><img src="img/3.jpg" alt=""></li> <li><img src="img/4.jpg" alt=""></li> <li><img src="img/5.jpg" alt=""></li> <li><img src="img/6.jpg" alt=""></li> </ul> <img src="img/l.png" alt="" id="lef"> <img src="img/r.png" alt="" id="rig"> <ol> <li class="focus" data-i = "0"></li> <li data-i = "1"></li> <li data-i = "2"></li> <li data-i = "3"></li> <li data-i = "4"></li> <li data-i = "5"></li> </ol> </div> 2. js part <script> var liList = document.querySelectorAll("#box ul li") var olList = document.querySelectorAll("#box ol li") var rig = document.getElementById("rig") var lef = document.getElementById("lef") var index = 0 function setLi(){ for(var i = 0;i <liList.length;i++){ liList[i].className = "" olList[i].className = "" } liList[index].className = "show" olList[index].className = "focus" } //Rightrig.onclick = function(){ if(index !== 5){ index++ } if(index === 5){ index = 0 } setLi() } //Left lef.onclick = function(){ if(index !== 0){ index-- } if(index === 0){ index = 5 } setLi() } //Point for(var i = 0;i < olList.length;i++){ olList[i].onclick = function(){ index = this.getAttribute("data-i") setLi() } } // Timing var autoPlay = setInterval( function(){ rig.click() },3000) //Move the mouse over to stop playing var box = document.querySelector("div") box.onmouseenter = function(){ clearInterval(autoPlay) } // Move the mouse away and continue playing box.onmouseleave = function(){ autoPlay = setInterval( function(){ rig.click() },3000) } </script> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to implement second-level scheduled tasks with Linux Crontab Shell script
>>: mysql obtains statistical data within a specified time period
Problem <br />In responsive layout, we shou...
Table of contents 1. Purpose 2. Grammar 3. Practi...
Block element HTML tag classification details * a...
1: Define a stored procedure to separate strings ...
According to null-values, the value of null in My...
Each of these 16 sites is worth reading carefully,...
vmware workstations starts the virtual machine er...
question By clicking a control, a floating layer ...
The div+css layout to achieve 2-end alignment is ...
Table of contents Download tf-gpu Build your own ...
Table of contents 1. Cancel duplicate requests 2....
This article example shares the specific code of ...
1. Command Introduction The gzip (GNU zip) comman...
This article uses an example to illustrate the us...
Viewing and Setting SQL Mode in MySQL MySQL can r...