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

150
Views
¿Por qué mi script no encuentra el elemento con esta identificación?

Tengo este elemento img en mi archivo html:

 <div id="runningQuizBoxForFlag"> <div class="flagBoxQuiz"> <img id="a" src="https://flagcdn.com/h120/im.png" srcset="https://flagcdn.com/h240/im.png 2x" alt="Isle of Man"> </div> </div>

y cuando intento acceder a él desde mi archivo mecanografiado, no encuentra el elemento y devuelve un valor nulo.

 const img: HTMLImageElement = document.getElementById('a') as HTMLImageElement; console.log("img is " + img); img.src = "https://flagcdn.com/h120/" + country.code + ".png"; //error occurs here img.srcset = "https://flagcdn.com/h240/" + country.code + ".png"; img.alt = country.alt;

con este error: TypeError no capturado: no se pueden establecer las propiedades de nulo (estableciendo 'src')

Cambié la identificación a "a" para no cometer errores de ortografía, pero todavía no funciona.

about 4 years ago · Juan Pablo Isaza
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!