I want to render animation for next image in a div, that when I press arrow button every time it render animation of next image in that div. I have tried this code please help.
$(document).ready(function() {
var i = 0;
$(document).keydown(function(e) {
if (e.which == 39) {
$("#mydiv:eq(i)").animate({
left: "-=50"
});
}
i++;
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="thing">
<span>0</span>
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
</div>