Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我的列表动画有什么问题?_Javascript_Jquery_Css_Animation - Fatal编程技术网

Javascript 我的列表动画有什么问题?

Javascript 我的列表动画有什么问题?,javascript,jquery,css,animation,Javascript,Jquery,Css,Animation,基本上,我想让我的无序列表项一行一行地动画。 因此,最初,这是一行文本的动画开始方式 var spanWidth = $('ul.imagelist span').width(); $('ul.imagelist span').animate( { width: spanWidth }, 3000 ); 所以,为了让五个无序列表一个接一个地动画化,我想我可以使用setTimeout函数,这里是我已经尝试过的,你可以在结果窗口中看到它似乎消失了,滑入并返回,我不确定发生了什么。如果您能提供一些帮

基本上,我想让我的无序列表项一行一行地动画。 因此,最初,这是一行文本的动画开始方式

var spanWidth = $('ul.imagelist span').width();
$('ul.imagelist span').animate( { width: spanWidth }, 3000 );
所以,为了让五个无序列表一个接一个地动画化,我想我可以使用setTimeout函数,这里是我已经尝试过的,你可以在结果窗口中看到它似乎消失了,滑入并返回,我不确定发生了什么。如果您能提供一些帮助或指导,我们将不胜感激。

请尝试以下方法:

JS:

$('ul.imagelist span').each(function(i) {  
  var t = $(this); 
  setTimeout(function() {  
    t.parent(".text").show();
    t.animate( { width: t.width() }, 1000);
  }, (i + 1) * 1000);  
});
.text{
  display:none;
}
CSS:

$('ul.imagelist span').each(function(i) {  
  var t = $(this); 
  setTimeout(function() {  
    t.parent(".text").show();
    t.animate( { width: t.width() }, 1000);
  }, (i + 1) * 1000);  
});
.text{
  display:none;
}

您希望它们最初被隐藏并滑入?检查此修改您正在为每个迭代执行多个函数,当您已经通过每个元素时,无需通过cicle选择每个元素。啊,很好,是的,最好先隐藏,然后一次滑入一个元素。