【发布时间】:2014-04-14 12:00:43
【问题描述】:
我有图像,当鼠标悬停时我想要一个 div,但我不希望它在鼠标移出。我写了代码,它可以工作,但它在闪烁。 这是代码:
<div id="div" style="opacity:0.6; background-color:#2c3e50; width:136px; height:163px; z-index:199; position:absolute; vertical-align:top; font-size:120px; text-align:center; color:White; display:none;">1</div>
<img alt="ברק לוי" src="" style="background-color:red; height:163px; width:136px" onmouseover="picture(true)" onmouseout="picture(false)"/>
function picture(bool) {
if (bool) {
document.getElementById("div").style.display = "block";
}
else if (bool==false) {
document.getElementById("div").style.display = "none";
}
}
jsBin 我该如何解决?
【问题讨论】:
标签: javascript html onmouseover onmouseout