абсолютно ничего сложного, пару строк кода ))
<html>
<head>
<title>example</title>
<style>
.bl
{
width: 50px;
height: 50px;
margin: 10px;
border: 1px solid black;
float: left;
}
</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 ()
{
this.style.backgroundColor = 'black';
if (prev)
prev.style.backgroundColor = '';
if (prev == this)
prev = undefined;
else
prev = this;
}
});
</script>
</body>
</html>