change img src in each 5 sec with three photo with Jquery -


images

  1. sf.jpg
  2. sf2.jpg
  3. sf3.jpg

change above img src in each 5 sec in first 5 sec image should sf.jpg in second 5 sec image should sf2.jpg in third 5 sec image should sf3.jpg

and should work repeatdly forever

check below code snippet.

i have altered alt attribute after 2 secs. in code replace alt src.

$(window).on('load', function() {    let src = ['image_1.jpg', 'image_2.jpg', 'image_3.jpg', 'image_4.jpg'];    let = 1;    setinterval(function() {      $('img').prop('alt', src[i]);      if (i !== src.length)        i++;      else        = 0;    }, 2000);  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <img src='image_1.jpg' alt='image_1.jpg' width='200' height='200' />

hope, works you. :) :)


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -