• <jQuery> <方法> 十五. scrollTop()方法和scrollLeft()方法


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            body {
                width: 2000px;
                height: 2000px;
            }
        </style>
    </head>
    <body>
    
    
    <div></div>
    <input type="button" value="顶部">
    <input type="button" value="左边">
    <script src="jquery-3.2.1.js"></script>
    <script>
        $(function () {
            $(window).scroll(function () {
                // 距离上边的距离
                console.log($(window).scrollTop());
    
                // 距离左边的距离
                console.log($(window).scrollLeft());
            });
        });
    </script>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            body {
                width: 2000px;
                height: 2000px;
            }
        </style>
    </head>
    <body>
    
    
    <div></div>
    <input type="button" value="顶部">
    <input type="button" value="左边">
    <script src="jquery-3.2.1.js"></script>
    <script>
        $(function () {
            $(window).scroll(function () {
                // 距离上边的距离
                console.log($(window).scrollTop());
    
                // 距离左边的距离
                console.log($(window).scrollLeft());
            });
        });
    </script>
    </body>
    </html>
  • 相关阅读:
    North North West
    HDU-5387 Clock
    HDU-1036 Average is not Fast Enough!
    Growling Gears
    HDU-5375 Gray code
    HDU-5373 The shortest problem
    hdu-5364 Distribution money
    UVA
    HDU-5363 Key Set
    HDU-5326 Work
  • 原文地址:https://www.cnblogs.com/ZeroHour/p/8276583.html
Copyright © 2020-2023  润新知