Need help in how to describe the function of the arrows "right" and "left" on the slider! There are pictures when clicking on which the slider starts directly, there are two arrows on the slider (I didn’t add styles, just two black squares)! Here directly with them and a hitch:
miniImg = document.getElementsByClassName("img"); close = document.getElementById("close"); bigSlideWrap = document.getElementById("mstrbig"); bigImg = document.getElementById("bigImg"); aL = document.getElementById("arrowLeft"); aR = document.getElementById("arrowRight"); for(var i=0; i<miniImg.length; i++){ miniImg[i].onclick=function(e){ bigSlideWrap.style.display="block" bigImg.src=e.target.src } }; aL.onclick=function(){ alert("Arrow left") //в этих фукнциях и есть вопрос } aR.onclick=function(){ alert("Arrow right") //в этих фукнциях и есть вопрос } close.onclick=function(){ bigSlideWrap.style.display="none" };
.mini-img-wrap{ width: 300px; height: 200px; margin: 100px auto; } .mini-img{ width: 30%; height: 100%; float: left; margin-right: 10px; } .img{ width: 100%; height: 100%; transition: all 0.5s; } .big-img-wrap{ position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: gray; display: none; } .close{ position: absolute; right: 0px; width: 50px; height: 50px; background: red; text-align: center; line-height: 50px; cursor: pointer; } .big-img{ position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 300px; height: 400px; background: black; } .arrowRight{ position: absolute; width: 30px; height: 30px; background: black; top: 50%; right: 10px; z-index: 99; transform: translate(0,-50%); display: block; } .arrowLeft{ position: absolute; width: 30px; height: 30px; background: black; top: 50%; left: 10px; z-index: 99; transform: translate(0,-50%); display: block; }
<div class="mini-img-wrap"> <div class="mini-img"> <img src="https://www.stihi.ru/pics/2013/03/21/3655.jpg" id="img" class="img" alt=""> </div> <div class="mini-img"> <img src="https://www.stihi.ru/pics/2005/12/19-543.jpg" id="img" class="img" alt=""> </div> <div class="mini-img"> <img src="https://static.baza.farpost.ru/v/1536487862393_bulletin" id="img" class="img" alt=""> </div> </div> <div class="big-img-wrap" id="mstrbig"> <div class="close" id="close">close</div> <div class="big-img"> <div class="arrowRight" id="arrowRight"></div> <div class="arrowLeft" id="arrowLeft"></div> <img class="big-img" id="bigImg" src="#" alt=""> </div> </div>
If there is a ready-made solution, I would like to see it with the current data, if this is not realistic, then you can try to create an array of the values of these pictures, personally I don’t understand yet how to access the current picture loaded in the slider, and already with her somehow start flipping! Please write the answer exclusively in native JavaScript, without using library syntax!