ещё вариант ...
<html>
<head>
<title>example</title>
<style>
.bl
{
width: 50px;
height: 50px;
margin: 10px;
border: 1px solid black;
float: left;
}
.black{
background: #000000
}
</style>
</head>
<body>
<div style="width: 400px; overflow: hidden;">
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
<div class="bl"></div>
</div>
<script>
var prev;
Array.prototype.forEach.call(document.querySelectorAll('.bl'), function (ths)
{
ths.onclick = function ()
{
var black = document.querySelector('.black');
if(!this.classList.contains('black') && black) black.classList.remove('black');
this.classList.toggle('black');
}
});
</script>
</body>
</html>