Answers for "how to assign image to a variable in javascript"

0

how to assign image to a variable in javascript

<div id="x"></div>

<script>
var img = document.createElement("img");
 
img.src = "image.png";
var src = document.getElementById("x");
 
src.appendChild(img);
</script>
Posted by: Guest on May-15-2020
0

javascript image to variable

document.body.appendChild(img1);
document.querySelector(".some-class").appendChild(img1);
document.getElementById("someId").appendChild(img1);
Posted by: Guest on July-11-2021
0

javascript image to variable

<img id="score1" class="hidden">
<img id="score2" class="hidden">
<img id="score3" class="hidden">

.hidden { display: none; }

var score2Element = document.getElementById("score2");
score2Element.classList.remove("hidden");
Posted by: Guest on July-11-2021

Code answers related to "how to assign image to a variable in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language