<div class="col">1</div>
<div class="col">2</div>
<div class="col">3</div>
<script>
var elements = document.querySelectorAll('div.col'),
len = elements.length,
clickdiv = function () {
this.style.background = "red";
alert('blah-blah');
};
for (var i = 0; i < len; i++) {
elements[i].onclick = clickdiv;
}
</script>