I'm looking for a way to make a list of 5 elements automatically scroll through each one every 3 seconds. Once it reaches the last element, I want it to loop back and start again from the first element. Here is what I've tried so far.
var height = $(".list li:first-child").outerHeight();
setInterval(function(){
$('.list').animate({
scrollTop: 58
}, 500);
}, 3000);
.list{width: 200px;height: 180px;overflow: auto;list-style: none;padding-left: 0px;}
ul.list li{padding:20px 0px;}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<ul class="list">
<li>Option 01</li>
<li>Option 02</li>
<li>Option 03</li>
<li>Option 04</li>
<li>Option 05</li>
</ul>
Currently, the list only scrolls to the second element and then stops. Can anyone suggest a solution to fix this issue?
Your assistance would be greatly appreciated.