分享web开发知识

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

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

jquery点击回到顶部

发布时间:2023-09-06 02:36责任编辑:顾先生关键词:暂无标签
<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>回到顶部</title> ???<meta name="viewport" content="width=1200, maximum-scale=1.0, user-scalable=1"> ???<style> ???????.scrollToTop{ ???????????display: block; ???????????width: 42px; ???????????height: 42px; ???????????position: fixed; ???????????bottom: 5%; ???????????right: 2%; ???????????display: none; ???????????font-size: 40px; ???????????background: #232323; ???????????color: #ebebeb; ???????????border-radius: 3px; ???????????text-align: center; ???????????line-height: 38px; ???????????z-index: 999; ???????} ???????.scrollToTop i img{margin:9px 0px 0px 2px;} ???</style></head><body style="height:2000px"> ???????<a href="#" title="sroll" class="scrollToTop"><i><img src="https://www.cnblogs.com/images/cnblogs_com/wrongcode/1426773/o_uptop0.png" ></i></a><script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script><script type="text/javascript"> ???????$(window).scroll(function() { ???????????if ($(this).scrollTop() > 300) { ???????????????$(‘.scrollToTop‘).fadeIn(); ???????????} else { ???????????????$(‘.scrollToTop‘).fadeOut(); ???????????} ???????}); ???????$(‘.scrollToTop‘).on("click", function() { ???????????$(‘html, body‘).animate({ ???????????????scrollTop: 0 ???????????}, 800); ???????????return false; ???????});</script></body></html>

jquery点击回到顶部

原文地址:https://www.cnblogs.com/phplearn/p/10610513.html

知识推荐

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