I use Sportlink javascript library and I’m trying to show logo of football clubs on the page. This library prints only links like:
So I’m trying to move this string to an img tag and I almost succeeded without any knowledge of javascript or jquery.
When I click the button I get a logo image, which I want. But I would like to show the logo on page load without clicking anything.
Example page: https://alcides.ineeditweb.nl/teams/test-team/
// Javascript library (embedded) code
<div
data-article="programma"
data-param-gebruiklokaleteamgegevens="NEE"
data-param-eigenwedstrijden="JA"
data-param-aantalregels="1"
data-param-thuis="JA"
data-param-uit="JA"
data-label-thuisteamlogo="thuislogo"
data-fields="thuisteamlogo"
></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").on( "click", function(){
var a = $("div[data-label-thuisteamlogo='thuislogo']").text().replace("thuislogo", "");
let img = document.createElement("img");
img.src = a;
document.getElementById("test").appendChild(img);
});
});
</script>
<button>Return value</button>
<label id="test" style="width:60px" height="60px"></label>