2
Studying about array I understood that array = document.querySelectorAll(".nomeClasse")
returns an array that contains each element that uses this class. But it’s still unclear to me how you access the elements within the created array.
<tbody id="tableTask">
<tr class="task">
<td class="infoIndice">1</td>
<td class="infoTask">Limpar Cozinha</td>
</tr>
<tr class="task">
<td class="infoIndice">1</td>
<td class="infoTask">Recolher Cocô do Cachorro</td>
</tr>
</tbody>
In this example I use task = document.querySelectorAll(".task")
and receive an array with 2 elements that are the 2 <tr>
who use class task
.
How, from there, I have access to the second td
? (Collect Poop from the Dog)
If I want to change the contents of this td
for example. there is some kind of "task[1].td(infoTask).innerHTML = "lavar a roupa";
"?
After a while I realized I could use the
querySelectorAll
with thetask
as we do withdocument
. It’s something trivial but I started my studies a short time ago and it’s so much information that it takes a little bit for the brain to digest and make these connections automatically. But it was nice to have asked the question because I didn’t know the method to usechildren[x]
. Thanks for the answer, I was prestres to answer my own question when you answered her. :)– Daniel Carvalho de Oliveira
@Danielcarvalhodeoliveira I’m glad to have helped :)
– Sergio