document.getElementsByClassName('asd')[0].addEventListener('click',function(){console.log('click!')},false);
var elements = document.getElementsByClassName("asd"),
length_of_elements = elements.length,
setContent = function(){
this.innerHTML = 'lol';
}, i;
for (i=0;i<length_of_elements;i++) {
elements[i].addEventListener('click',setContent,false);
}
function on(arg, function_to_apply) {
if (Array.ifArray(arg)) {
for (i = 0; i < arg.length; i++ ) {
function_to_apply( arg[i] );
}
} else {
function_to_apply( arg );
}
}
el.addEventListener('click', handler, false);
el.addEventListener('click', handler, true);
el.removeEventListener('click', handler);
el.removeEventListener('click', handler);
el.removeEventListener('click', handler, false);
el.removeEventListener('click', handler, true);
<body>
<div id="block">
...
<div class="section" id="section-%number%">
</div>
...
</div>
</body>
var makingColumsInterval = setTimeout(function rekurs(){
if(randNumbersArray.length === columQty){
clearTimeout(makingColumsInterval);
}
var randomNum = getRandomNum(1, columQty);
if(randNumbersArray.indexOf(randomNum) === -1) {
randNumbersArray.push(randomNum);
outputNumbers("section-" + randNumbersArray[randNumbersArray.length - 1]);
}
var makingColumsInterval = (rekurs(),100);
},100);
if(randNumbersArray.length === columQty){
clearTimeout(makingColumsInterval);
}
makingColumnsInterval = setInterval(function (){
if(randNumbersArray.length === columQty){
clearInterval(makingColumnsInterval);
return;
}
var randomNum = getRandomNum(1, columQty);
if(randNumbersArray.indexOf(randomNum) === -1) {
randNumbersArray.push(randomNum);
outputNumbers("section-" + randNumbersArray[randNumbersArray.length - 1]);
}
}, 100);