in an HTML page, i've got 7 buttons whit the following IDs: #I, #II, #III, #IV, #V, #VI, #VII placed in a rContainer div. I want to set the iActiveButton variable in correlation with the touched button. My code seems to work properly but i feel that it could be enhanced and shortened. Any idea?
var iActiveButton;
function touchHandler(){
console.log(iActiveButton);
}
rContainer.addEventListener("touchstart", function(){
I.addEventListener("touchstart", function(){iActiveButton = 1;}, false);
II.addEventListener("touchstart", function(){iActiveButton = 2;}, false);
III.addEventListener("touchstart", function(){iActiveButton = 3;}, false);
IV.addEventListener("touchstart", function(){iActiveButton = 4;}, false);
V.addEventListener("touchstart", function(){iActiveButton = 5;}, false);
VI.addEventListener("touchstart", function(){iActiveButton = 6;}, false);
VII.addEventListener("touchstart", function(){iActiveButton = 7;}, false);
touchHandler();
}, false);