下面我就为大家分享一篇js实现延迟隐藏功能的方法(类似qq头像鼠标放上展示信息),具有很好的参考价值,希望对大家有所帮助。
JS实现延迟隐藏
nbsp;html>延迟隐藏 #p1{ 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; } #p2{ 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; } window.onload=function(){ var p1=document.getElementById("p1"); p1.innerHTML="鼠标请放上!"; var p2=document.getElementById('p2'); p2.innerHTML="鼠标请移开!"; var timer=null; p1.onmouseover= function(){ clearTimeout(timer); p2.style.display='block'; }; p1.onmouseout= function(){ clearTimeout(timer); timer= setTimeout(function(){ p2.style.display='none'; }, 700); }; p2.onmouseover=function(){ clearTimeout(timer); }; p2.onmouseout=function(){ clearTimeout(timer); timer=setTimeout(function(){p2.style.display='none';},700); } }
登录后复制
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
详细解读Angular有关报错404问题
详细解读Angular有关报错404问题
详细解读Angular有关报错404问题
以上就是通过JS如何实现延迟隐藏功能的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/3184477.html