Мой JavaScript не в хорошем состоянии в данный момент, и я озадачен с этим!
Я должен создать анимированный список с JavaScript как этот - http://www.fiveminuteargument.com/blog/scrolling-list.
То, что я хочу, должно взять список как так
- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
- Item 6
И отобразитесь два сразу, затем отобразите их в цикле, 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();
});
}
Просто модификация кода Юваля, чтобы заставить работать "два за раз":
$(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();
});
}