jquery-3.6.0.min.js下載(鏈接如下)
Download jQuery | jQuery
html返回頂部的代碼,如圖,右鍵選擇Download the compressed....,點擊將鏈接另存為:
?保存在你想要的路徑下:
網頁點空白處回到頂部。強調一點:
<script>中的src處路徑格式為:file:\\\你的jquery-3.6.0.min.js存放地址\jquery-3.6.0.min.js
(這種寫法是為了幫助純小白同學,有一定基礎的朋友可直接換為相對路徑)
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>測試</title><!-- src處填寫你剛下載好了的jquery-3.6.0.min.js文件路徑 --><script type="text/javascript" src="file:\\\你的jquery-3.6.0.min.js存放地址\jquery-3.6.0.min.js"></script><style>#box {position: fixed;bottom:30px;right: 30px;}#back_to_top{border:1px solid #888;}.text{height: 3000px;width: 200px;}</style>
</head>
<body>
<!-- 此處可將button換做好看的圖標,但id需保持一致 -->
<div id="box" title="我是按鈕"><button id="back_to_top">返回頂部</button></div><!-- 此處用于填充頁面,以展示效果 -->
<div class="text"></div><script type="text/javascript">var backButton=$('#back_to_top');function backToTop() {$('html,body').animate({scrollTop: 0}, 500); //這里的500用于調整滾動條回滾速度 ,例如還可改為:1000,700等}backButton.on('click', backToTop);$(window).on('scroll', function () {if ($(window).scrollTop() > ($(window).height()))backButton.fadeIn();elsebackButton.fadeOut();});$(window).trigger('scroll');
</script>
</body>
</html>
靜態網頁如何實現登錄?好了,大功告成!最后可將相應代碼移植到項目中為網頁添加上這個功能。
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态