Jquery回到顶部效果

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type = "text/css">
        #sp{ position:fixed; top:70%; left:82.5%; cursor:pointer;}
    </style>
    <script type = "text/javascript" src = "JueryPractice/jquery-1.7.2.min.js"></script>
    <script type ="text/javascript">
        $(document).ready(function () {
            $("#sp").hide();
            $(function () {
                $(window).scroll(function () { //移动浏览器的滚动条时触发
                    if ($(window).scrollTop() > 100) {
                        $("#sp").fadeIn(1000);
                    }
                    else {
                        $("#sp").fadeOut(1000);
                    }
                });
            });
            $("#sp img").click(function () {
                $("body,html").animate({ scrollTop: 0 }, 1500, false);
            });

            //匹配id为sp选择器紧邻的第一个选择器
            $("#sp + p").click(function () {
                $("#sp + p").animate({ "height": 300 }); //改变元素的高度
            });

            $("#chui").click(function () {
                alert($(window).scrollTop()); //获取滚动条距离浏览器顶端的垂直高度
            });

            $("#shui").click(function () {
                alert($(window).scrollLeft());
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <p id = "sp"><span></span><img src = "images/2011082113443606.gif.jpg" alt = "无法显示" /></p>
    <p style = " position:absolute; top:2000px; cursor:pointer; background-color:Green">顶部</p>
    </div>
    </form>
</body>
</html>

时间: 2024-08-29 10:35:23

Jquery回到顶部效果的相关文章

自写jquery网页回到顶部效果,渐隐图标,引用js文件即可

唔,进来开发需求,当网页内容草鸡多的时候,用户就需要有个按钮快速回到顶部,而不是自己去滚滑轮~ 原本以为比较难的说,因为上头要求全部用js来实现,哪个页面引用,哪个页面显示. 于是乎,本屌丝就尝试写了下,唔,没发现,还挺easy的说~~ 有屁我就快放了,直接上代码,屁放多了就成屎了~~唔,罪过,阿弥陀佛,阿门~~ $(function(){ var $btn_top = $('<a id="scrollTop"><img src="css/web/image

jquery实现&quot;跳到底部&quot;,&quot;回到顶部&quot;效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ

JavaScript实现的回到顶部效果

参考自:http://www.imooc.com/learn/65 几乎所有的网站都会有回到顶部的功能,可以直接用锚点(#)实现,但是跳转的很生硬. 1.使用插件,我之前在介绍两个JQuery插件 — 滚动和轮播说过一个滚动插件,使用效果不错. 我在自己的小项目使用了:旅行笔记 2.原生的JS实现. 有两个点,一个是window 的滚动事件:window.onscroll,另一个是setInterval和clearInterval. 具体内容见代码,里面注释了. window.onload =

用Javascript实现回到顶部效果

用Javascript实现回到顶部效果 经常看到网页中有回到顶部的效果,今天也研究一下回到顶部有哪些方法.众所周知,用锚链接是实现回到最简单的方法,但是从用户体验效果来说,并不是最好的.(锚链接回到顶部时太快了,而且用户可能在看到某个感兴趣的东西想停下来,却停不下来),针对上面的缺点,我们试着用Javascript的方法来得到实现.思路是这个样子的: 1.首先用html和css构建基本的例子,代码如下 html部分: <div class="box"> <img sr

jQuery回到顶部插件jQuery GoUp

插件描写叙述 jQuery GoUp!是一个简单的jQuery插件,让你的网页用户直接回到顶部. 用法很easy 引用jquery库和jquery.goup.min.js到你的页面 <script type="text/javascript" src="jquery.min.js"></script> <script type="text/javascript" src="jquery.goup.min.j

html css jquery 回到顶部按钮

今天做了个回到顶部的功能,在这里记录一下,有需要可以拿去试试! CSS部分,很简单就一个class /*回到顶部*/ .back-top { position: fixed; right: 15px; bottom: 15px; z-index: 9999; font-size: 25px; width: 40px; height: 40px; background-color: #adadad; color: #ffffff; cursor: pointer; border-radius: 2

实用的回到顶部效果

在各大网站上我们都可以看到一个回到顶部按钮,但它是怎么做的呢? 其实很简单,我们只需要将scrollTop的值置为0即可.但为了让回滚的效果更舒服,我们需要利用一点运动学的知识让页面滚动的速度由快变慢,例如speed = scrollTop/8. 先给出布局代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>

jquery回到顶部源码分享-

// JavaScript Document (function($){ var goToTopTime; $.fn.goToTop=function(options){ var opts = $.extend({},$.fn.goToTop.def,options); var $window=$(window); $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body'))

回到顶部效果

<style> .box { width: 1190px; margin: 0 auto; } #btn { width: 40px; height: 40px; background: url(images.png) no-repeat left top;//回到顶部的小箭头 position: fixed; left: 50%; margin-left: 600px; bottom: 30px; display: none; } #btn:hover { background: url(i