我正在尝试将鼠标悬停在弹出的默认图像的更大图像上。但是,每当我将鼠标悬停在较小的图像上时,它就会弹出,但是当我将鼠标悬停在弹出图像上时,它会继续闪烁。
下面是我的代码:
HTML:
<div class="thumbnail" id="thumbnail1">
<img src="image1.jpg" onmouseover="enlarge1()" onmouseout="minimize1()"/>
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
function enlarge1() {
var parent = document.getElementById("thumbnail1");
var child = document.createElement("IMG");
child.setAttribute("src", "image-large1.jpg");
child.setAttribute("width", "350%");
child.setAttribute("alt", "Related Large 1");
child.style.position="absolute";
child.style.zIndex="1";
child.style.bottom="15%";
child.style.left="30%";
parent.appendChild(child);
}
function minimize1() {
var parent = document.getElementById("thumbnail1");
var child = parent.lastElementChild;
parent.removeChild(child);
}
Run Code Online (Sandbox Code Playgroud) 我一直在环顾四周,看看是否有人真的这样做过,但找不到,所以希望我能在这里得到一些帮助。
newDict = {'Jan':31, 'Feb':29, 'Mar':31, 'Apr':30, 'May':31, 'Jun':30, 'Jul':31, 'Aug':30}
Run Code Online (Sandbox Code Playgroud)
我创建了这个 dict,我想使用while循环以这种方式输出它:
Jan 31
Feb 29
Mar 31
Apr 30
May 31
Jun 30
Jul 31
Aug 30
Run Code Online (Sandbox Code Playgroud)
我可以用for循环来完成,只是好奇如何用while循环来完成。