Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
How do I take a URL stored in a variable in JS and pass it to HTML file?

I am a beginner so I'm sure this is probably obvious.

I have an API call which finds current news for a location which I have stored in a variable called newsUrl. I wish to show this in my HTML file within a modal.

here is the code for my modal

<div id="newsModal" class="modal">   
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-heading">News</h4>
          <button type="button" class="btn-close"  aria-label="Close"></button>
      </div>
      <div class="modal-body">
          <table class="table table-striped">
    <tbody>
     
        <tr>
          
          <td><p id="txtNews"></p></td>

        </tr>
        
      
     
  </table>
  </div>
        </div>
      </div>

I have tried the following code within my JS file

newsUrl = result['data'][0]['url'];
          newsImage = result['data'][0]['image'];
          newsTitle = result['data'][0]['title'];
          

          newsLink = ('<a href="//'+newsUrl+'" target=_blank ></a>');
             
          $('#txtNews').html(newsLink);

No errors in the console.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try to use: $('#txtNews').append(newsLink);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda