Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
cómo convertir una variable JS en un elemento html

Soy nuevo en Javascript y quiero poder mostrar una variable JS en mi página sin que el usuario acceda a la consola, ya que es más ordenado, y encuentro que mucha gente no conoce la consola, y yo no quiere usar el código alert() . ¿Alguien puede ayudar?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

El siguiente código accede al párrafo con id "test" e imprime el valor de "testVariable" en él.

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

about 4 years ago · Juan Pablo Isaza Report

0

Creo que esto es lo que necesita, pero este ejemplo es muy simple. Le recomiendo que busque más en Google y mantenga abierto el documento de JavaScript para cualquier pregunta.

La definición de innerHTML .

La propiedad del elemento innerHTML obtiene o establece el marcado HTML o XML contenido en el elemento.

 // 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!