[英]Make hover to whole div by JS
當我想將鼠標懸停到div時,它將懸停整個div div
我試圖設置疊加層的高度,但是它丟失了!
<div id="Overlay" onmouseover="hoverDown()" onmouseout="hoverUp()" onload="muteOther()">
#Overlay {
width: 100%;
height: 100%;
position: absolute;
opacity: 0;
}
function hoverUp() {
var a = document.getElementById("Overlay");
a.style.opacity = "0";
a.style.transition = "all 1s";
}
function hoverDown() {
var a = document.getElementById("Overlay");
a.style.opacity = "1";
setTimeout(function () {
a.style.opacity = "0";
a.style.transition = "all 1s";
}, 4000);
}
當l將光標移至div時,將顯示其Overlay,而當out時,Over絕望
嘗試將JavaScript包含在<script>
標記內。 另外,您可以在js中使用attr_for_div=func(this)
和func(this)
, this
等於var a=doc...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.