Показать сообщение отдельно
  #2 (permalink)  
Старый 23.10.2014, 00:50
Аватар для Vlasenko Fedor
Профессор
Отправить личное сообщение для Vlasenko Fedor Посмотреть профиль Найти все сообщения от Vlasenko Fedor
 
Регистрация: 13.03.2013
Сообщений: 1,572

<style>
  .red {
    color: red;
  }
</style>
<p class="hello">Lorem ipsum dolor sit amet, consectetur</p>
<p class="hello">Sapiente in delectus dolorem reiciendis ditii</p>
<p class="hello">Quis dolore autem voluptatibus repellat</p>
<script>
  function next(len) {
    var i = -1;
    return function () {
      i++;
      return i == len ? -1: i;
    };
  }
  var allP = document.querySelectorAll('p.hello'),
    pos = next(allP.length),
    current,
      timer = setInterval(function () {
      current = pos();
      if (current == -1) {
        clearInterval(timer);
      } else {
        allP[current].className += ' red';
      }
    }, 2000);
</script>

Последний раз редактировалось Vlasenko Fedor, 23.10.2014 в 01:11.
Ответить с цитированием