W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".btn1").click(function(){ alert($("div").scrollLeft()+" px"); }); }); </script> </head> <body> <div style="border:1px solid black;width:100px;height:130px;overflow:auto"> The longest word in the english dictionary is: pneumonoultramicroscopicsilicovolcanoconiosis. </div> <button class="btn1">获得滚动条的水平位置</button> <p>试着移动滚动条,然后再次点击按钮。</p> </body> </html>