更新时间:2023-12-04 22:50:22
您需要转义i
.现在,nth-child
正在寻找索引为i
而不是0
,1
,2
等的子级.因此,请使用:
You need to escape i
. Right now, nth-child
is looking for the child that has an index of i
, not of 0
, 1
, 2
, etc. So instead, use:
$('#slideshow p:nth-child(' + i + ')').fadeIn('slow').delay(800).fadeOut('slow');
但是,我认为这不会一次完成.实际上,我敢肯定不会.如果没有,请尝试以下操作:
However, I don't think that will do one at a time; in fact, I'm pretty sure it won't. If it doesn't, try something like this:
var delay = 0;
$('#slideshow p').each(
function (index, item)
{
$(this).delay(delay).fadeIn('slow').delay(800).fadeOut('slow');
delay += 2200;
}
);
未经测试,但至少应该是不错的伪代码.
That's untested, but should be decent pseudocode at the very least.