+ 3
How to add a image in javascript that you can display with html?
So, Im making a dice program. But im trying to like visualise the dices. So i need to like make it display a image when it rolls 1 using the random math function. Whats the code for javascript and html to add the image? This would help me alot :D ( this is my try to add it ) but it doesnt show it sadly.. https://code.sololearn.com/WgHbEcMdo0G8
3 Respuestas
+ 6
"use strict";
this.onload=()=>{
var img= new Image();
img.src="";
document.body.appendChild(img)
}
+ 5
this.onload=()=>{
var img = document.createElement("img");
img.src = "https://www.google.com/url?sa=i&source=images&cd=&ved=2ahUKEwiQq8ugvu7iAhVCEVAKHS-iD94QjRx6BAgBEAU&url=https%3A%2F%2Fen.m.wikipedia.org%2Fwiki%2FFile%3ADice-1.svg&psig=AOvVaw1PWOz2UaDsDp9qiX2wPaHM&ust=1560790447185018";
var src = document.getElementById("x");
src.appendChild(img)
}
//your trying
+ 3
thanks!!