Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda