zoukankan      html  css  js  c++  java
  • jquery scroll()方法 语法

    jquery scroll()方法 语法

    作用:当用户滚动指定的元素时,会发生 scroll 事件。scroll 事件适用于所有可滚动的元素和 window 对象(浏览器窗口)。scroll() 方法触发 scroll 事件,或规定当发生 scroll 事件时运行的函数。dd直驱电机

    触发scroll事件:$(selector).scroll()

    将函数绑定到scroll事件:$(selector).scroll(function)

    参数:

    参数 描述
    function     可选。规定当发生 scroll 事件时运行的函数。

    jquery scroll()方法 示例

    <html>
    <head>
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script type="text/javascript">
    x=0;
    $(document).ready(function(){
      $("div").scroll(function() {
        $("span").text(x+=1);
      });
    });
    </script>
    </head>
    <body>
    <p>请试着滚动 DIV 中的文本:</p>
    <div style="200px;height:100px;overflow:scroll;">text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. 
    <br /><br />
    text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text.</div>
    <p>滚动了 <span>0</span> 次。</p>
    </body>
    </html>
  • 相关阅读:
    NYOJ 35
    TOJ 3072
    HDU 1075
    POJ 1028
    TOJ 1153
    TOJ 1036
    POJ 1521
    POJ 3253
    NYOJ 467
    HDU 1671
  • 原文地址:https://www.cnblogs.com/furuihua/p/11977249.html
Copyright © 2011-2022 走看看