Trying to create a straightforward image slider.
Below is the provided JavaScript code:
$(document).ready(function() {
$('#slide1_images').on('click', 'img', function(){
$("#slide1_images").css("transform","translateX("+$(this).index() * -450+"px)");
});
});
The issue seems to be that it doesn't register a click on the correct image but rather on the next one. Any suggestions?
Here's a live example: