Smike,
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<style type='text/css'>
* {
margin: 0;
padding: 0;
}
ul {
list-style: none;
}
#container {
position: relative;
top: 20px;
width: 640px;
height: 480px;
margin: 0 auto;
box-shadow: 0 0 5px 5px rgba(0, 0, 0, .5);
transition: all .2s;
background: no-repeat center center;
}
#previous {
position: absolute;
left: 10px;
top: 50%;
margin-top: -20px;
opacity: .5;
cursor: pointer;
}
#previous:hover, #next:hover {
opacity: 1;
}
#previous:active {
margin-top: -18px;
}
#next:active {
margin-top: -18px;
}
#next {
position: absolute;
right: 10px;
top: 50%;
margin-top: -20px;
opacity: .3;
cursor: pointer;
}
.nav {
position: absolute;
bottom: 0;
left: 50%;
width: 100px;
margin-left: -50px;
}
.nav li {
float: left;
margin-right: 5px;
margin-bottom: 5px;
display: block;
height: 10px;
width: 10px;
border: 2px solid #fff;
border-radius: 50%;
}
.active {
background-color: red;
}
</style>
<script>
window.onload = function() {
(function() {
var container = document.getElementById("container"),
button = document.getElementById("next"),
previous = document.getElementById("previous"),
array = ["http://www.umnet.com/pic/diy/screensaver/3845b123-a01a.jpg", "http://www.iceis.pl/640x480/640x480_-_niagarafalls640x480.jpg", "http://www.umnet.com/pic/diy/screensaver/87832121-ea64.jpg", "http://www.blackberry-wallpapers.com/uploads/allimg/110514/2-1105142029510-L.jpg"],
sliderRules = document.querySelectorAll(".nav li"),
j = sliderRules.length - 1,
imgSet = function(link) {
container.style.backgroundImage = "url(" + link + ")";
};
container.addEventListener("click", newX, false);
for (; j > -1; j--) {
var sliderRule = sliderRules[j];
sliderRule.dataset.indx = j;
};
sliderRule.classList.add("active");
sliderRule.click();
function newX(e) {
var elem = e.target;
var i = +elem.dataset.indx;
if (isNaN(i)) return;
var next = i + 1;
next == array.length && (next = 0);
var prev = i - 1;
0 > prev && (prev = array.length - 1);
button.dataset.indx = next;
previous.dataset.indx = prev;
document.querySelector('.active').classList.remove("active");
sliderRules[i].classList.add("active")
var link = array[i];
var img = new Image();
img.onload = function() {
imgSet(link);
};
img.src = link;
img.complete && img.onload();
e.preventDefault();
}
}());
}
</script>
</head>
<body>
<div id="container">
<img src="https://www.gentec-eo.com/Content/images/home/slider/left-arrow.png" id="previous" width="40" height="40" >
<img src="https://www.gentec-eo.com/Content/images/home/slider/right-arrow.png" id="next" width="40" height="40" >
<ul class="nav">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>