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

214
Visualizações
How to take Data from a div and put it into a JS array

html:

<div id="array"></div>

App 1: inserts data into a html div

 document.getElementById('array').innerText = data;

App 2: takes data from html

 let new_data = document.getElementById('array').innerText

Is it possible to turn new_data into an array and if so how?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

with new_data, you can use .innerText/.textContent/.innerHTML, whichever works to your liking to get the content inside, and then, since it is a string, you can just use .split() if you wish to split it. If the content is a JSON object, you can use JSON.parse(the_string_here) to get a JSON object / Array from a string into the respective object.

If that doesn't help, could you share what the content of the html div looks like, so I could get a better understanding of what you're trying to accomplish?

about 4 years ago · Juan Pablo Isaza Relatório

0

You can simply take a storage variable and push the values from the div into it.

A simple example, which you probably still have to adjust.

const storage = []
document.getElementById('array').innerText = 'Hello';
storage.push( document.getElementById('array').innerText )


let newData = document.getElementById('array').innerText = document.getElementById('array').innerText + ' World';
storage.push(newData)
console.log(storage)
<div id="array"></div>

about 4 years ago · Juan Pablo Isaza Relatório
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