0

I want to trigger an animation if the user reaches a certain scroll position (or if he is certain pixels from the end of the page)

Therefore i used this code: https://jsfiddle.net/rt1LsofL/

    $(window).scroll(function() {
      var scroll = $(window).scrollTop();
      if (scroll >= 100) {
      $(".ober-inner").addClass("animate");
      }
    });

It seems the class isn't added to the element and so the animation is not triggered. I already tried to insert an alert at the end of the js code which is working.

Thanks for your help.

user4075462
  • 115
  • 1
  • 9
  • 1
    Who ever closed this was wrong, the actual answer is JQuery is not included it, it works as expected if JQuery is included. – Andrew Bone May 18 '16 at 13:28
  • https://jsfiddle.net/rt1LsofL/2/ - a proof – Velimir Tchatchevsky May 18 '16 at 13:35
  • 1
    This is not a duplicate, the other question is about jQuery not being able to use its "addClass" method on SVG, which is not true as of jQuery 2.2 and doesn't concern the problem the OP is experiencing. The fact is the OP didn't include jQuery which is his only problem. Question is out of topic (maybe) but not `and exact duplicate` – Velimir Tchatchevsky May 18 '16 at 14:17
  • Thank you very much!!! i completely forgot to include the JQuery in my Fiddle. I worked with jquery 2.2.0 in my original html file. Problem solved! – user4075462 May 18 '16 at 14:41

0 Answers0