scrolling h2 elements with scrollTo in jquery -


I was thinking that anyone can help me with this scrolling problem using the scrollTo plugin for jquery . I want to be able to scroll one H2 element at a time with one click ... in my script it scrolls in all the H2 elements with one click..please thank me guys! Click $ (document) .ready (function ($ ('# down') (function () {$ ("# container H2"). Each (function (i, h2 ) {$ ("# Wrap"). Scroll (H2, 800, click on {$ ('' #) (function () {$ ("# container H2") .reverse (). (H2, 800, {axis: 'y'});});}); jQuery.fn.reverse = function Back to (this.get) reverse (), logic);};});

OK, you are calling each () so that you can call each h2 Scroll over per click to see which element you scrolled and scrolled to the next one, like:

  $ (document) .ready (function () {var next = 0; $ ('# Down'). (Function () {$ ("# wrap"), scrolltou ($ ("# container H2"). Eq (next), 800, {axis: 'y'}) ; Next ++;}}}};  

Update:

You must ensure that the counter does not increase or decrease more Does. I have also changed a bit that do not always use the selector to find all h2 elements. It is enough to get them once you are on the last element, then counter check should also be fixed and click below (again when you are in the first element and above < / Code> click]:

  $ (document) .ready (function () {var element = $ ("# container h2"); var next = 0; var max = elements Click on the line ($ 1 & lt; max) next to (+ 1 & lt; max) {next ++; $ ("# wrap") .Scroll (element [ Next], 800, {axis: 'y'});}}); $ ((next # 1) {if--; $ ("# wrap"). Take], 800, {axis: Y '});}});});  

Comments