分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

jQuery 返回顶部效果

发布时间:2023-09-06 01:21责任编辑:胡小海关键词:jQuery
<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>返回顶部</title> ???<script src="scripts/jquery-1.7.1.min.js"></script></head><body><script type="text/javascript"> $(function(){var toppos = 0;$(".back_top_index").hide();$(document).scroll( ?function(){ ???toppos=$(document).scrollTop(); ???var oClient =$(window).height();//当前窗口可视区域高度 ???if(toppos>oClient){ ?????$(".back_top_index").fadeIn(); ?????}else if(toppos==0){ ?????$(".back_top_index").fadeOut(); ????} ?})$(".back_top_index").click(function(){ ???$("html,body").animate({scrollTop:0}) ?}) ??})</script> <div style="height:2000px;">3423424</div><div class="back_top_index">1</div><style>.back_top_index{width: 50px;height: 50px;position: fixed;bottom: 10px;right: 10px;background-color: red;}</style></body></html>

jQuery 返回顶部效果

原文地址:http://www.cnblogs.com/arealy/p/7765537.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved