当前位置: 移动技术网 > IT编程>开发语言>JavaScript > javascript实现延时显示提示框效果

javascript实现延时显示提示框效果

2018年04月28日  | 移动技术网IT编程  | 我要评论
js延时提示框效果演示: 实现方法 移入显示,移出隐藏 移除延时隐藏,可以实现从第一个div移入第二个div,仍然可以显示 <!

js延时提示框效果演示:

实现方法

移入显示,移出隐藏

移除延时隐藏,可以实现从第一个div移入第二个div,仍然可以显示

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<style>
#div1 {
 width: 50px;
 height: 50px;
 background: red;
 float: left
}
#div2 {
 margin-left: 10px;
 width: 250px;
 height: 150px;
 background: yellow;
 float: left;
 display: none
}
</style>
<script>
window.onload=function()
{
 var odiv1=document.getelementbyid('div1');
 var odiv2=document.getelementbyid('div2');
 var timer=null;
 odiv1.onmouseover=odiv2.onmouseover=function()
 {
 cleartimeout(timer);
 odiv2.style.display='block';
 };
 odiv1.onmouseout=odiv2.onmouseout=function()
 {
 timer=settimeout(function()
 {
  odiv2.style.display='none';}
 ,500); 
 };
};
</script>
<body>
<div id="div1"></div>
<div id="div2"></div>
</body>
</html>

github源码地址

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网