Home > Mobile >  Add array of objects as elements to existing table td
Add array of objects as elements to existing table td

Time:05-07

I have an existing table. I have the td cells displayed as blocks intentionally. :) My goal is to add labels inside each of the td's by creating spans with a specific class, then prepend them to the table cell. I'm using an array of objects with the label data, an 'icon' and a 'name'.

The Goal

I'm having trouble applying the icons individually to the td's. They all get grouped together on each cell.

enter image description here

A few issues I'm trying to solve:

  1. Add each object (one icon and one label) to each cell
  2. When creating the elements, add an icon class to the icon span and an label class to the label span.
  3. Apply them appropriately in the order shown in the object

I've tried a bunch of different things (see code comments) and lots of good posts here on SO but this function seems to get me the closest to my goal. Any help is very much appreciated.

let items = [{
    id: "           
  • Related