4 ms·
I figured that was the normal way to interact with tables, what would people do otherwise?
by eterm 11mo ago
I figured that was the normal way to interact with tables, what would people do otherwise?
- xg15 11mo agoUsing the standard DOM APIs or - if they don't care about anything - innerHTML, I suppose.
- kleiba 11mo 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 11mo 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 11mo 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 11mo agocreateElement(‘tr’) and table.appendChild(row)