1

I am trying to make "tabs" so that when a user clicks on one, the portion below the tab changes to display the information relevant to that tab. To do so, I am using getElementsByClassName(). I want to get the index of the clicked tab from the array returned by getElementsByClassName(). How can I do this?

This is what I have right now:

var options = document.getElementsByClassName("option");
var k;
for (k = 0; k < options.length; k++) {
    options[k].addEventListener("click", function() {    
            hideAllOptionInformationExcept(/*INDEX OF CLICKED ELEMENT IN ARRAY*/);
    });
}
Jake Xia
  • 81
  • 9

0 Answers0