Hello! There is a slider, on the left is the name of the article, and on the right is a picture, and according to the relevant news the necessary picture is displayed. Here is the code responsible for the actions described:

$(document).ready(function(){ $(".leftBlock").hover( function(){ $(".leftBlock").css('background-image','none'); $(this).css('background','url("/img/arrow4.png")'); $(this).css('background-repeat','repeat'); $("#image").attr("src",$(this).attr("img_href")) }, function(){ $("#image").attr("src") } ); }); 

Question: How to make "autoscrolling" or "auto-stepping"?

  • [Just too lazy to google ...] [1] [1]: yeap.narod.ru/js/022.html - Palmervan
  • Yes, I'm not talking about the sliders, then I know, this one is samopisny) - Goldy

1 answer 1

 function slideNews(){ var lb = $('.leftblock'); // новостные блоки var lba = $('.leftblock.arrowed'); // выделенный блок if(!lba.length) lb.eq(0).addClass('arrowed'); // если нет выделенных блоков - выделяем первый else{ lb.eq((lb.index(lba) + 1) % lb.length).addClass('arrowed'); // выделяем следующий блок lba.removeClass('arrowed'); // с текущего убирем выделение } $("#image").attr('src', lba.attr('img_href')); // показываем картинку setTimeout(slideNews, 5000); // 5 секунд - все по новой } slideNews(); // ПУСК! 

In general, indeed, it is usually easier to google.

  • +1 for google - zippp