I'm pretty new to web development (coming from an AV control system programming background) and am trying to do something that I'm convinced has to be super easy, but I'm coming up short. Basically I've created an array variable of buttons on a document, and need to determine which button was pressed. For example, let's say I have four buttons with ID's "id1" - "id4" Here's what I've got in JS:
$(document).ready(function(){
var sourceBtns = [];
var lastPressedIndex;
for(i=1;i<=4;i++){
sourceBtns.push(document.getElementById("id"+i));
}
for(i=1;i<=sourceBtns.length;i++){
sourceBtns[i-1].addEventListener("click",lastPressed);
}
function lastPressed(){
//need to assign lastPressedIndex here
}
});