jQuery实现页面下拉100像素出现悬浮窗口的方法
网络编程 2021-07-04 20:00www.168986.cn编程入门
这篇文章主要介绍了jQuery实现页面下拉100像素出现悬浮窗口的方法,涉及jQuery事件监听及针对页面元素的判定与动态操作技巧,需要的朋友可以参考下
本文实例讲述了jQuery实现页面下拉100像素出现悬浮窗口的方法。分享给大家供大家参考,具体如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://.w3./TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://.w3./1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JS 页面下拉100像素出现悬浮窗口</title> <script src="js/jquery-1.10.1.min.js" type="text/javascript"></script> </head> <body> <div style="height:5000px;"></div> <style type="text/css"> .fdPhone{position:fixed; _position:absolute; width:320px; height:50px; position:fixed; left:50%; margin-left:-160px; :0px; display:none;} </style> <div class="fdPhone"> <a href="tel:123456789" target="_blank"><img src="images/phone.gif" width="320" height="50"></a> </div> <script type="text/javascript"> $(function(){ $(window).scroll(function() { if($(window).scrollTop() >= 100){ //向下滚动像素大于这个值时,即出现浮窗~ $('.fdPhone').fadeIn(300); //浮窗淡入的时间,越小出现的越快~ }else{ $('.fdPhone').fadeOut(300); //浮窗淡出的时间,越小消失的越快~ } }); $('.actGo').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);}); //浮窗动画停留时间,越小消失的越快~ }); </script> </body> </html>
效果图:
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》及《》
希望本文所述对大家jQuery程序设计有所帮助。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程