So I made a horizontal slider of some cards and i am able to make them scroll left on click of a button but how do I get a button, which on clicked scrolls right?
<div id="recCard-slider">
<p><i class="fas fa-chevron-left" id="scrollRight"></i> <i class="fas fa-chevron-right" id="scrollLeft" ></i></p>
<div id="content">
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
</div>
</div>
const buttonleft = document.getElementById('scrollLeft');
buttonleft.onclick = function(){
document.getElementById('content').scrollLeft +=100;
}
I have #content
with overflow-x: scroll
and white-space: nowrap;
I want the Icon "chevron-left"
for scrolling back (right).