jQuery nextAll 以各函数无返回为准
以下代码旨在将一个过程应用于单击之前和之后容器的所有子元素。它以某种方式被破坏了。我从未使用过 nextAll 或 prevAll 因此它可能与错误的编码有关。
$('.bounceholder ul').prevAll().each(function(){
$(this + ' li').each(function(){
$(this).animate({left: -200, top:-8, leaveTransforms:true}, 600);
});
});
$('.bounceholder ul').nextAll().each(function(){
$(this + ' li').each(function(){
$(this).animate({left: +1000, top:-8, leaveTransforms:true}, 600);
});
});
问题出在哪里
The following code was designed to apply a procedure to all the child elements of containers before and after the one being clicked. It is broken in some way. I have never used nextAll or prevAll so it is probably related to bad coding.
$('.bounceholder ul').prevAll().each(function(){
$(this + ' li').each(function(){
$(this).animate({left: -200, top:-8, leaveTransforms:true}, 600);
});
});
$('.bounceholder ul').nextAll().each(function(){
$(this + ' li').each(function(){
$(this).animate({left: +1000, top:-8, leaveTransforms:true}, 600);
});
});
Where's the problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
Try this:
已经给出了一个很好的答案(使用
this
作为上下文,而不是尝试将其与字符串li
连接),但您可以使用siblings
作为更短的替代方案:prevAll
返回所有前面的同级,并且 < code>nextAll 返回以下所有内容所选元素的同级元素,siblings
应提供完全相同的功能,但只需要一个代码块。A good answer has already been given (using
this
as a context rather than trying to concatenate it with the stringli
) but you could usesiblings
as a shorter alternative:As
prevAll
returns all the preceding siblings, andnextAll
returns all the following siblings of the selected element,siblings
should provide exactly the same functionality but only requires the one block of code.