Is it possible to move output value of embedded code to a <img src”>?
The embed code example:
<!-- Paste this where you want the article to appear -->
<div
data-article="programma"
data-param-teamcode="245124"
data-param-gebruiklokaleteamgegevens="NEE"
data-param-aantalregels="1"
data-param-aantaldagen="60"
data-param-eigenwedstrijden="JA"
data-param-thuis="JA"
data-param-uit="JA"
data-format-wedstrijddatum="DD-MM-YYYY"
data-fields="thuisteam, thuisteamlogo"
></div>
has the following output:
<div data-article="programma" data-param-teamcode="245124" data-param-gebruiklokaleteamgegevens="NEE" data-param-aantalregels="1" data-param-aantaldagen="60" data-param-eigenwedstrijden="JA" data-param-thuis="JA" data-param-uit="JA" data-format-wedstrijddatum="DD-MM-YYYY"
data-fields="thuisteam, thuisteamlogo">
<table class="article programma">
<thead>
<tr>
<th><span class="string">Thuisteam</span></th>
<th><span class="string">Thuisteam logo</span></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="string">De Weide 2</span></td>
<td><span class="string">https://binaries.sportlink.com/KNVB-production-DOCUMENT/280B8A5A8EF81EC7C0CAC19267EC8683?expires=1724879248&sig=a6a97cac503271e0515ce3dfd4d66b330d819e25</span></td>
</tr>
</tbody>
</table>
</div>
The URL in the output is a link to an image and I would like to view the image in the browser instead of just a link.
Is it possible to move this with javascript/jquery to <img src=''>
??
Didn’t try anything yet
2
Answers
If you’re asking if you can set the SRC attribute of an IMG with JQuery, sure you can –
Say you have an image:
You can set the src attribute like this:
$("#image").attr("src","https://binaries.sportlink.com/KNVB-production-DOCUMENT/280B8A5A8EF81EC7C0CAC19267EC8683?expires=1724879248&sig=a6a97cac503271e0515ce3dfd4d66b330d819e25");
You can target images by classes or IDs and unset, swap or set almost any attribute, including src.
Vanilla JS – note the css to restrict the height of the logo
jQuery: