<button id="scroll-up">Up 5 lines</button>
<button id="scroll-down">Down 5 lines</button>Window: scrollByLines() method / notebook
Window: scrollByLines() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
document.getElementById("scroll-up").addEventListener("click", () => {
window.scrollByLines(-5);
});
document.getElementById("scroll-down").addEventListener("click", () => {
window.scrollByLines(5);
});