<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
</head>
<body>
<div class="col">1</div>
<div class="col">2</div>
<div class="col">3</div>
<div class="rez">Rezult 1</div>
<div class="rez">Rezult 2</div>
<div class="rez">Rezult 3</div>
<script>
var elements = document.querySelectorAll('div.col'),
result = document.querySelectorAll('div.rez'),
len = elements.length,
clickdiv = function (i) { return function () {
result[i].style.background = "red";
alert(i); }
};
for (var i = 0; i < len; i++) {
elements[i].onclick = clickdiv(i);
}
</script>
</body>
</html>