Well i put tablerows with a classname "gone" in my Html like this:
<tr class="gone">
<th>text</th>
<td>text</td>
</tr>
<tr class="gone">
<th>text</th>
<td>text</td>
</tr>
<tr class="gone">
<th>text</th>
<td>text</td>
</tr>
<tr class="gone">
<th>text</th>
<td>text</td>
</tr>
<tr class="gone">
<th>text</th>
<td>text</td>
</tr>
<tr class="gone">
<th>text</th>
<td>text</td>
</tr>
and when i get my elements in javascript with this code:
var arrayelements=document.getElementsByClassName('gone');
var arrlength=arrayelements.length;
for(var i=0;i<arrlength;i++){
arrayelements[i].setAttribute("class","there");
console.log(arrayelements);
}
the return value of my console.log is
> <tr class="there">...</tr>
> <tr class="there">...</tr>
> <tr class="there">...</tr>
> undefined
the next time i run it the result is
> <tr class="there">...</tr>
> <tr class="there">...</tr>
> undefined
i don't understand why it is suddenly undefined