Alexander Belov,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.slider{
display: none;
}
.slider.visible{
display: block;
}
</style>
</head>
<body>
<div class="slider">1</div>
<div class="slider">2</div>
<div class="slider">3</div>
<div class="slider">4</div>
<div class="slider">5</div>
<script>
var items = document.querySelectorAll(".slider"), len = items.length, indx = len-1;
(function foo()
{
items[indx].classList.remove("visible");
indx = ++indx % len;
items[indx].classList.add("visible");
window.setTimeout(foo, 300)
})()
</script>
</body>
</html>