Edit in JSFiddle

var $=function(id){
return document.getElementById('bt'+id);
}
for(var i=1;i<6;i++){    
    $(i).onclick=function(){
        alert(i);
    }
}
<button id='bt1'/>bt1</button>
<button id='bt2'/>bt2</button>
<button id='bt3'/>bt3</button>
<button id='bt4'/>bt4</button>
<button id='bt5'/>bt5</button>