function creatOneSnow(){
var leftX = Math.random()*window.innerWidth;
var topY = Math.random()*window.innerHeight;
var snowDiv = document.createElement("div");
snowDiv.style.position = "fixed";
snowDiv.style.left = leftX + "px";
snowDiv.style.top = topY + "px";
snowDiv.innerHTML = "<img src="image/snow.png" width="20px" />";
document.body.appendChild(snowDiv);
}
The js above works correctly, and I want to set the width for the image element independently.
the test failed. Excuse me, how should I write it?
function createOneSnow(){
var leftX = Math.random()*window.innerWidth;
var topY = Math.random()*window.innerHeight;
var snowDiv = document.createElement("div");
snowDiv.style.position = "fixed";
snowDiv.style.left = leftX + "px";
snowDiv.style.top = topY + "px";
snowDiv.innerHTML = "<img src="image/snow.png" id="myImg" />";
var targetImg = document.getElementById("myImg");
targetImg.style.width = "20px";
document.body.appendChild(snowDiv);
}
how do I modify it?