0

I started programming a bit with HTML/CSS/js and I have a table with several rows with 2 elements each I was wondering how it's possible to give certain td Elements a text through a JavaScript function without giving them all an unique id or something.

I am searching for something similar to

for(i = 0; i < 10; i++) {
  table.at[i] = i+3;
}

and I am missing the at[i] part for it.

1
  • Use document.querySelector() with an nth-child selector? Commented Nov 24, 2021 at 23:54

1 Answer 1

-1

You could use the children attribute

If you want to access the nth row of a table, use table.children[n+1] (first child of table is the header, if you don't have a header remove the +1). If you want to get to row y and column x, table.children[y+1]. children [x].

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.