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

250
Views
¿Cómo agrego texto al final en un elemento de texto en html a través de js?

Quiero agregar texto al final en el elemento ap, no primero, pero solo sé cómo agregar el último usando +=

 var pEL = document.querySelector("#text"); pEL.innerHTML += "1";
 <p id="text">text</p>

ahora el elemento p dice "texto1" pero quiero "1texto", ¿cómo agrego algo primero en un elemento de texto?

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

0

pE1.innerHTML += "1";

es simplemente una forma abreviada de decir "el nuevo html será el antiguo html + "1"

 pEl.innerHTML = pEl.innerHTML + "1"

así que en su lugar, algo como

 pEL.innerHTML = "1" + pEl.innerHTML

debería hacer el truco.

about 4 years ago · Juan Pablo Isaza Report

0

La propiedad del elemento innerHTML obtiene o establece el marcado HTML o XML contenido dentro del elemento, así que configúrelo concatenando 1 + el texto anterior (llamar a pEL.innerHTML sin asignación es básicamente usar get para obtener el valor)

 var pEL = document.querySelector("#text"); pEL.innerHTML = "1" + pEL.innerHTML;
 <p id="text">text</p>

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!