David David - 2 months ago 5
CSS Question

Button scrolling down screen after click stops, after another click starts again

I've got a little problem.
Here's my fiddle:


My question is: what's wrong with my code? Point is that I want to scroll site down after clicking button and after another click I want to stop, then to proceed.
I used:
Please help!


The button onclick function is wrong. Change it to whatever function you'd want to call in your JS code.

Also change your JSFiddle's JS setting "Load Type" to "No wrap in - <head>"

Here is updated logic for your code.

var scrolling = false;
var scrollDelay;

function scrollClick() {
    if (!scrolling) {
    scrolling = true;
  } else {
    scrolling = false;

function startScroll() {
    window.scrollBy(0, 50); // horizontal and vertical scroll increments
  scrolldelay = setTimeout('startScroll()', 125); // scrolls every 100 milliseconds

function stopScroll() {

Here is the updated fiddle https://jsfiddle.net/ekpgbxrk/5/