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.
Try to use: $('#txtNews').append(newsLink);