Edit The Code:
See Result »
Try it Yourself - ©
w3big.com
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>本教程(w3big.com)</title> <script src="http://cdn.static.w3big.com/libs/jquery/1.10.2/jquery.min.js"> </script> <script> x=0; $(document).ready(function(){ $("div").scroll(function(){ $("span").text(x+=1); }); $("button").click(function(){ $("div").scroll(); }); }); </script> </head> <body> <p>尝试滚动 div 中的滚动条</p> <div style="border:1px solid black;width:200px;height:100px;overflow:scroll;">本教程 —— 学的不仅是技术,更是梦想!本教程 —— 学的不仅是技术,更是梦想! <br><br> 本教程 —— 学的不仅是技术,更是梦想!本教程 —— 学的不仅是技术,更是梦想!</div> <p>滚动了 <span>0</span> 次。</p> <button>触发窗口的 scroll 事件</button> </body> </html>