1. 程式人生 > 實用技巧 >jquery滾動條

jquery滾動條

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title></title>
        <script src="jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script
> <style type="text/css"> #box { background-color: red; height: 300px; width: 300px; } </style> <script type="text/javascript"> $(document).ready(function() { $(
"#s-top-get").click(function() { $("p").text("scrollTop()獲取" + $(document).scrollTop()); }); $("#s-top-set").click(function() { $(document).scrollTop(70); }); }); </script> </head>
<body> <div id="box"> </div> <button type="button" id="s-top-get">scrollTop()獲取</button> <button type="button" id="s-top-set">scrollTop()設定</button> <p></p> </body> </html>