JS實現(xiàn)延遲隱藏功能的方法(類似QQ頭像鼠標(biāo)放上展示信息)
更新時間:2017年12月28日 14:47:21 作者:玉面靈狐
下面小編就為大家分享一篇JS實現(xiàn)延遲隱藏功能的方法(類似QQ頭像鼠標(biāo)放上展示信息),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
JS實現(xiàn)延遲隱藏
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>延遲隱藏</title>
<style>
#div1{
width:100px;
height:100px;
background:yellow;
border: 5px solid #999;
border-radius: 10px;
position: absolute;
right: 50px;
text-align: center;
line-height: 100px;
margin-bottom:10px;
}
#div2{
width:200px;
float: left;
height:200px;
border: 5px solid #999;
border-radius: 10px;
position: absolute;
right:160px;
text-align: center;
line-height: 200px;
background:green;
display:none;
}
</style>
<script>
window.onload=function(){
var div1=document.getElementById("div1");
div1.innerHTML="鼠標(biāo)請放上!";
var div2=document.getElementById('div2');
div2.innerHTML="鼠標(biāo)請移開!";
var timer=null;
div1.onmouseover= function(){
clearTimeout(timer);
div2.style.display='block';
};
div1.onmouseout= function(){
clearTimeout(timer);
timer= setTimeout(function(){
div2.style.display='none';
}, 700);
};
div2.onmouseover=function(){
clearTimeout(timer);
};
div2.onmouseout=function(){
clearTimeout(timer);
timer=setTimeout(function(){div2.style.display='none';},700);
}
}
</script>
</head>
<body>
<div id="div1"></div>
<div id="div2"></div>
</body>
</html>

以上這篇JS實現(xiàn)延遲隱藏功能的方法(類似QQ頭像鼠標(biāo)放上展示信息)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
cookie丟失問題(認(rèn)證失效) Authentication (用戶驗證信息)也會丟失
window.showModalDialog() 后 window.open() 導(dǎo)致cookie丟失問題(認(rèn)證失效) Authentication (用戶驗證信息)也會丟失2009-06-06
JS如何將數(shù)字金額轉(zhuǎn)換成中文金額格式
這篇文章主要介紹了JS如何將數(shù)字金額轉(zhuǎn)換成中文金額格式,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-07-07
JavaScript中的數(shù)組遍歷forEach()與map()方法以及兼容寫法介紹
下面小編就為大家?guī)硪黄狫avaScript中的數(shù)組遍歷forEach()與map()方法以及兼容寫法介紹。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05
詳解JavaScript中的執(zhí)行上下文及調(diào)用堆棧
這篇文章主要介紹了JavaScript中的執(zhí)行上下文及調(diào)用堆棧,對此感興趣的同學(xué),可以參考下2021-04-04

