Scolling перечисляют с jQuery

Мой JavaScript не в хорошем состоянии в данный момент, и я озадачен с этим!

Я должен создать анимированный список с JavaScript как этот - http://www.fiveminuteargument.com/blog/scrolling-list.

То, что я хочу, должно взять список как так

  • Item 1
  • Item 2
  • Item 3
  • Item 4
  • Item 5
  • Item 6

И отобразитесь два сразу, затем отобразите их в цикле, 2 за один раз.

Даже псевдо код помог бы запустить меня.

5
задан Chris 28 February 2010 в 23:30
поделиться

2 ответа

С помощью HTML, включенного в ваше сообщение, вы можете выполнить следующее.

$(document).ready(function(){
    //hide all the list items
    $("ul li").hide();
    //call the function initially
    show_list_item();
});

function show_list_item(){
    //fade in the first hidden item. When done, run the following function
    $("ul li:hidden").first().fadeIn("slow", function(){
       //if there are no more hidden list items (all were shown), hide them all
       if($("ul li:hidden").length == 0){
          $("ul li").hide();
       }
       //call this function again - this will run in a continuous loop
       show_list_item();
    });
}
3
ответ дан 15 December 2019 в 06:24
поделиться

Просто модификация кода Юваля, чтобы заставить работать "два за раз":

$(document).ready(function(){
    //hide all the list items
    $("ul li").hide();
    //call the function initially
    show_list_item();
});

function show_list_item(){
    //fade in the first hidden item. When done, run the following function
    $("ul li:hidden:first").fadeIn("slow", function(){
       //if there are no more hidden list items (all were shown), hide them all
       if($("ul li:hidden").length == 0){
      $("ul li").hide();
       }
    });
    $("ul li:hidden:first").fadeIn("slow", function(){
       //if there are no more hidden list items (all were shown), hide them all
       if($("ul li:hidden").length == 0){
      $("ul li").hide();
       }
       //call this function again - this will run in a continuous loop
       show_list_item();
    });
}
0
ответ дан 15 December 2019 в 06:24
поделиться
Другие вопросы по тегам:

Похожие вопросы: