Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda