<div id="container">
<div id="content">Click the button to slide right!</div>
</div>
<button id="slide" type="button">Slide right</button>Element: scrollLeft property / notebook
Element: scrollLeft property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
#container {
width: 100px;
height: 100px;
border: 1px solid #cccccc;
overflow-x: scroll;
}
#content {
width: 250px;
background-color: #cccccc;
}const button = document.getElementById("slide");
button.onclick = () => {
document.getElementById("container").scrollLeft += 20;
};