Here, try this. Much updated. I haven’t tested it fully, but it should work on major browsers back to IE8.
Changes you need make: Put your scrolling content in an element with a “data-scroller” attribute (like
<div data-scroller>My scrolling content!</div>). If you want more than one scroller on a page, you need to collect them all (e.g.,
querySelectorAll('[data-scroller'])) and call the
scroller function on each. The script needs to run on load (i.e., on document
ready, or put the script tag at the bottom of the page).