Javascript 将jquery脚本与waypoints JS连接

Javascript 将jquery脚本与waypoints JS连接,javascript,jquery,html,jquery-waypoints,Javascript,Jquery,Html,Jquery Waypoints,我已经在我的网站上加入了脚本。现在我想用一些jquery连接这个脚本。如果内容在视口中,脚本应“启动” 在我使用的另一个网站上 $('.fly-in-animation').waypoint(function() { $(this.element).addClass('animated fadeInUp'); }, { offset: '100%' }); 但我不知道如何将waypoints脚本与以下jquery连接: $({countNum:

我已经在我的网站上加入了脚本。现在我想用一些jquery连接这个脚本。如果内容在视口中,脚本应“启动”

在我使用的另一个网站上

$('.fly-in-animation').waypoint(function() {
              $(this.element).addClass('animated fadeInUp');
          }, { offset: '100%' });
但我不知道如何将waypoints脚本与以下jquery连接:

$({countNum: $('#counter-laender').text()}).animate({countNum: 14}, {
  duration: 2000,
  easing:'linear',
  step: function() {
    $('#counter-laender').text(Math.floor(this.countNum));
  },
  complete: function() {
    $('#counter-laender').text(this.countNum);
  }
});

将中的示例代码与您提供的代码结合使用(假设您希望在
#counter laender
进入视口时发生这种情况):


将中的示例代码与您提供的代码结合使用(假设您希望在
#counter laender
进入视口时发生这种情况):


没有,什么也没有出现。如果我去掉第一个变量code
var waypoint=new waypoint({element:document.getElementById('#counter laender'),handler:function(){myFunction();}})脚本不能正常工作。@JonasLoerken我编辑了这篇文章,很抱歉耽搁了。试试那个新代码。这是我能找到的最简单的航路点样板。还是不行吗?确保
myFunction()
或您正在使用的任何东西本身都是正确的。尝试将其替换为
alert()
console.log()
进行测试。否。什么也没有出现。如果我去掉第一个变量code
var waypoint=new waypoint({element:document.getElementById('#counter laender'),handler:function(){myFunction();}})脚本不能正常工作。@JonasLoerken我编辑了这篇文章,很抱歉耽搁了。试试那个新代码。这是我能找到的最简单的航路点样板。还是不行吗?确保
myFunction()
或您正在使用的任何东西本身都是正确的。尝试将其替换为
alert()
console.log()
进行测试。
$(document).ready(function() {
  $('#counter-laender').waypoint(function() {
    myFunction();
  });
});

function myFunction() {
    $({
        countNum: $('#counter-laender').text()
    }).animate({
        countNum: 14
    }, {
        duration: 2000,
        easing: 'linear',
        step: function () {
            $('#counter-laender').text(Math.floor(this.countNum));
        },
        complete: function () {
            $('#counter-laender').text(this.countNum);
        }
    });
}