jquery 航路点不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31199317/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 16:47:31  来源:igfitidea点击:

jquery waypoint is not working

jquery

提问by Kiran Dash

As per my code written below I think when I scroll to the .onscrollActivate div alert should come. But it is not giving me the alert.

根据我下面写的代码,我认为当我滚动到 .onscrollActivate div 警报时应该会出现。但它没有给我警报。

<div class="waypoint" style="width:100%;height:300px;"></div>

$(document).ready(function(){
    $('.onscrollActivate').waypoint(function() {
    alert();
  });
});

If I try .click()instead, it gives me the alert message.so my jquery is fine.

如果我尝试.click(),它会给我警报消息。所以我的 jquery 很好。

So, where am I going wrong?

那么,我哪里出错了?

回答by Tushar

As you see waypoint is not a functionerror in console, you haven't loaded the waypointlibrary on your page.

当您在 中看到waypoint is not a function错误时console,您还没有waypoint在页面上加载库。

Include waypointjs on the page after jQuery.

waypoint.js 之后的页面上包含js jQuery

<script src="https://cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.5/waypoints.min.js"></script>