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

242
Views
obtener un objeto javascript como un enlace

Necesito tu ayuda; quiero que el nombre obtenido de la matriz json sea un enlace; es decir, una vez que obtengo el nombre, hago clic en él para ser dirigido a una página (por ejemplo, se supone www.google.com ). Para ello utilicé la siguiente línea:

document.getElementById("demo").innerHTML = "+myObj["name"]+";

pero no consigo nada. ¿Alguien puede ayudarme por favor?

 const myJSON = '{"name":"John", "age":30, "car":null}'; const myObj = JSON.parse(myJSON); document.getElementById("demo").innerHTML = "<a href='http://www.google.com'>+myObj[" name "]+</a>";
 <h2>Access a JavaScript Object</h2> <p id="demo"></p>

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

0

document.getElementById("demo").innerHTML = "<a href='http://www.google.com'>"+myObj['name']+"</a>";

o

 document.getElementById("demo").innerHTML = `<a href='http://www.google.com'>${myObj["name"]}</a>`;
about 4 years ago · Juan Pablo Isaza Report

0

Usar literales de plantilla

 <html> <body> <h2>Access a JavaScript Object</h2> <p id="demo"></p> <script> const myJSON = '{"name":"John", "age":30, "car":null}'; const myObj = JSON.parse(myJSON); document.getElementById("demo").innerHTML = `<a href='http://www.google.com'>${myObj["name"]}</a>`; </script> </body> </html>

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!