我想触发一个事件,当jquery.localscroll到达文档的某一点,一个div。
假设我们从顶部的div垂直滚动到第三个。当它到达那里,然后行动schould触发。
解决方法
jQuery Waypoints插件
http://imakewebthings.github.com/jquery-waypoints/应该做的伎俩
更新
<!DOCTYPE html> <html lang="en"> <head> <Meta charset="utf-8"> <title>jQuery Waypoints Plugin - Test</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script> <script src="http://imakewebthings.github.com/jquery-waypoints/waypoints.min.js" type="text/javascript"></script> <style type="text/css"> #mydiv {background-color:#FF0000; margin:1500px 0;} </style> </head> <body> <div id="mydiv"> Content goes here </div> <script type="text/javascript"> $(function() { $('#mydiv').waypoint(function() { window.location.href = 'http://google.com'; },{ offset: '100%' }); }); </script> </body> </html>