Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
Using an array as the text content

I am trying to create a system to place a the values of the array into the text.

Array:

var records = [
    ['C', 'Descript']
    ['D', 'Test']
];

Creates the 'th' that I want to put the array values in.

let newColItem = document.createElement('th');

What I have tried:

galleryheader.textContent = records[i,1];

The i is from a for loop. No values a showing in the galleryheader cell. I can't find anything on how to put the array inside on the web, anyone got some idea of what to do.

All code if you need it:

const gallery_table = document.getElementById("gallery_table");
let list = ["A", "B"];
var idName = "";
var records = [
    ['C', 'Descript']
    ['D', 'Test']
];

for (let i = 0; i < list.length; i++) {
    if (i % 3 === 0) {
        var newRowItem = document.createElement("tr");
        idName = "newRowItem";
        idName = idName.concat(i);
        newRowItem.setAttribute("id", idName);
        gallery_table.appendChild(newRowItem);
    }
    let newColItem = document.createElement('th');
    let galleryheader = document.createElement('h3');
    newColItem.setAttribute("class", i);    
    newRowItem.appendChild(newColItem);
    newColItem.appendChild(galleryheader);
    galleryheader.textContent = records[i,1];


    const element = document.getElementById(idName);
    let nodes = element.getElementsByClassName(i);
    for (let j = 0; j < nodes.length; j++) {
        nodes[j].style.padding = "2px";
        nodes[j].style.width = "33%";
        nodes[j].style.border = "1px solid black";
    }
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda