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

166
Visualizações
how to render a JS variable into a html element

I am new to Javascript and want to be able to display a JS variable onto my page without the user going into the console as it is neater, and I find a lot of people don't know about the console, and I don't want to use the alert() code. Can anyone help?

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

0

The code below accesses the paragraph with id "test" and print the value of "testVariable" into it.

var testVariable = "hello";
document.getElementById("test").innerHTML = testVariable;
<p id="test"></p>

about 4 years ago · Juan Pablo Isaza Relatório

0

I think this is what you need but this example is very simple i recommend you to google more and to keep open the JavaScript Doc for any questions.

The definition for innerHTML.

The Element property innerHTML gets or sets the HTML or XML markup contained within the element.

// Your variable
let name = "Jhon"

// Get the HTML tag by ID and set the innerHTML
document.getElementById('name').innerHTML = name;
<div class="container">
  <p>Hello <span id="name"></span></p>
</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