0

Is there a way to access the variable i inside the anonymous mouseover function?

  for (var i = 0; i < results.length; i++) {
    results[i].addEventListener("mouseover", (function(event) {
      event.target.className = this.selectedClass;
      this.selectedIndex = i;
    }).bind(this), false);
    results[i].addEventListener("mouseout", (function(event) {
      event.target.className = '';
    }).bind(this), false);
  }

I did some research on closures, but I can't get it to work.

bernland
  • 688
  • 8
  • 16

0 Answers0