I'm trying to figure out the reason why I can't use an index twice in a loop,
there should be something very simple that I'm missing.
the structure of the code is like this:
<p id="one">test</p>
<p class="two">a</p>
<p class="two">b</p>
<p class="two">c</p>
<script>
var one = document.getElementById("one");
var two = document.getElementsByClassName("two");
var i = 0;
while (i < two.length) {
two[i].addEventListener("click", function() {two[i].innerHTML = one.innerHTML;});
i++;
}
</script>
any suggestion will be appreciated =)