Skip to content
Advertisement

auto scroll won’t animate at $(‘html,body’).animate

I’m working on a welcome page. I need one click to jump to the certain div and also a little scroll to jump to the next div. I’m not that good at javascript but I tried something and end up like this

JavaScript
JavaScript
JavaScript

I did the click function just fine, but the Auto Scroll or a Little Scroll or whatever it called to move to the next div when i scroll down a bit and move to the previous div when i scroll up a bit it’s not doing good.

  1. Did I mess up with the animate, $('html,body') at the end of JS?
  2. The logic should be = the div will be jump down when i scrolled down more or equal 40 and jump up when i scrolled up more or equal -20,
  3. i just figured it out if i change

    var a= document.getElementsByClassName(‘.IndexSection’); into

    var a= document.getElementsByTagName(‘div’); it moved, and almost like i wanted to.. but why i can’t use get elements by class names?

What am I missing? It should be perfect I think. Please help

Advertisement

Answer

sorry guys, I’m such an idiot it was a typo and LoL… it’s not a big deal it work just fine now…

typo at

JavaScript

i don’t need to put a dot before IndexSection class, so i just type it with this

JavaScript

all the code edited and it works fine now.. thx for u guys who respond

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement