1
I have a horizontal scroll, as I do to get the beginning and end of the scroll, I need to enable and disable the arrows.
function avancar() {
document.getElementById('elementos').scrollLeft += 20;
}
function voltar() {
document.getElementById('elementos').scrollLeft -= 20;
}
ul {
width: 500px;
border: solid 1px;
overflow: hidden;
overflow-x: auto;
white-space: nowrap;
padding: 0;
}
li {
display: inline-block;
width: 160px;
text-align: center;
}
li:first-child {
background: yellow;
}
li:last-child {
background: red;
}
a {
color: #333;
text-decoration: none;
margin: 20px;
}
<ul id="elementos">
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
</ul>
<a href="#" onClick="voltar();">< Voltar</a>
<a href="#" onClick="avancar();">Avançar ></a>