Basically, I have this image using the left and right arrow buttons. This image, by default, is the first frame that I extracted from some gif, the original gif contains 31 frames. My goal is when users press the right arrow button, I want to display the next frame and so on ... Everything works fine, as shown below. However, I need to add some kind of mouse event so that when the user clicks and holds the mouse, I want to continue to shoot at the following images. How can I achieve this?
$('#arrow_right').click(function (event) { event.preventDefault(); var data_id = parseInt($(this).parent().find('#inner_wrap img').attr('data-id')); if (data_id >= 1 && data_id <= 30) { data_id = data_id + 1; var avatar_num = $('#inner_wrap').html('<img id="avatar" data-id="' + data_id + '" src="img/avatar_test' + data_id + '.gif" width="90" height="200">'); } });
source share