Skip to content
Justice Tech School

Project: Image Slider

Rotate images with a timer.

Example
var i = 0, imgs = $(".slide");
setInterval(function () {
  imgs.eq(i).fadeOut();
  i = (i + 1) % imgs.length;
  imgs.eq(i).fadeIn();
}, 3000);

Exercise

Wrap around.

(i + 1)  imgs.length

Quiz Test

Why use the remainder?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.