4 ms·
It's about the insertRow() and insertCell() methods and rows[] and cells[] fields on the table element, not the table itself.
by xg15 1y ago
It's about the insertRow() and insertCell() methods and rows[] and cells[] fields on the table element, not the table itself.
- eterm 1y agoI figured that was the normal way to interact with tables, what would people do otherwise?
- xg15 1y agoUsing the standard DOM APIs or - if they don't care about anything - innerHTML, I suppose.
- kleiba 1y agoSorry I - also - am one of those old timers who don't understand this because the shown code is all I've ever used for creating table. So, what is this "standard DOM API" if I may ask? Could you post a code example?
- wging 1y agoYou can use document.createElement and document.appendChild to create every last <th>, <tr>, and <td> if you want. Those functions are not specific to tables, unlike the one mentioned in the blog post. They can be used to create any elements and place them in the DOM. But if you know what you are doing you can get a perfectly fine table out of that. (Not that you should.)
- xg15 1y agoYeah, that was what I was thinking of. I knew those as the essential APIs to modify the DOM without a full re-parse. And you can use them on table/th/tr/td nodes just like on any other node.
- thorum 1y agocreateElement(‘tr’) and table.appendChild(row)