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

175
Views
Cómo ingresar una variable para el p id = "variable"

Tengo el siguiente código

 <span id="X1a"> <script> document.getElementById("X1").innerHTML = 'Output1' document.getElementById("X2").innerHTML = 'Output2' <!---etc - several more similar lines for Outputx--> </script>

Lo que quiero hacer es poder ingresar (o seleccionar) el valor para poner en la línea id=. Entonces puedo elegir imprimir X1 o X2 o Xx. ¿Cómo puedo hacer eso?

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

0

puede usar setAttribute() para cambiar la id del valor. ejemplo

 document.getElementById("id").setAttribute("id", "X1")

o puede leer la referencia en w3school

https://www.w3schools.com/jsref/met_element_setattribute.asp

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!