I'm still very new to Javascript and working in different scenarios, sorry for anything you may see that could hurt your eyes!
So. I'm currently trying to insert text content that may change depending of image validation using a single class for multiple divs. Any help is appreciate!
JavaScript
var trophiestext = Array.from(document.querySelectorAll("spaner"));
trophiestext.forEach(function(troph) {
var trophy = document.getElementById("trophyimage");
if(trophy.src == "...//user/trophies/A.png"){
var x = document.getElementsByClassName("spaner");
x.textContent = "Trophy A";
}
else if (trophy.src == "...//user/trophies/B.png"){
var x = document.getElementsByClassName("spaner");
x.textContent = "Trophy B";
}
else{ var x = document.getElementsByClassName("spaner");
x.textContent = "Null";
}
HTML
...
<div id="trophies"><img id="trophyimage" src="{$host}/trophies/$UserTR" height="100" width="100">
<span id="spaner" class="text-content"></span></div>
Aucun commentaire:
Enregistrer un commentaire