无法删除 jQuery 变量中的嵌套列表
我有一个嵌套的有序列表,我使用此代码对其进行动画处理...
var $li = $("ol#update li");
function animate_li(){
$li.filter(':first')
.animate({
height: 'show',
opacity: 'show'
}, 500, function(){
animate_li();
});
$li = $li.not(':first');
}
animate_li();
现在我想要不显示嵌套列表(ol s)或 ols 中的 li 或对其进行动画处理,
请看一下示例此处
我的 ols 的结构是
<ol>
<li class="bar248">
<div class="nli">
<div class="pic">
<img src="dir/anonymous-thumb.png"alt="image" />
</div>
<div align="left" class="text">
<span>
<span class="delete_button"><a href="#" id="test" class="delete_update">R</a></span>
test shouted <span class="timestamp"> 2010/02/24 18:34:26 </span> <br />
this
</span>
</div>
<div class="clear"></div>
</div>
<div class="padd">
</div>
<ol class="comment">
<li>
<div>Testing </div>
</li>
<li>
<div>Another Test </div>
</li>
</ol>
</li>
</ol>
我可以使用此代码隐藏嵌套的 ols ...
$("ol#update li ol").hide();
但是尽管它们是隐藏的,但仍然消耗时间来对它们进行动画处理
我无法使用此代码删除嵌套的 li
var $li = $("ol#update li").not("ol#update li ol");
$li = $li.not("ol#update li ol");
看看这个 此处
任何帮助,
谢谢
巴杜
I have a nested oredered list which i m animating using this code...
var $li = $("ol#update li");
function animate_li(){
$li.filter(':first')
.animate({
height: 'show',
opacity: 'show'
}, 500, function(){
animate_li();
});
$li = $li.not(':first');
}
animate_li();
now i want not to show or animate the nested lists(ol s) or the li s in the ols
take a look at the example here
The structure of my ols are
<ol>
<li class="bar248">
<div class="nli">
<div class="pic">
<img src="dir/anonymous-thumb.png"alt="image" />
</div>
<div align="left" class="text">
<span>
<span class="delete_button"><a href="#" id="test" class="delete_update">R</a></span>
test shouted <span class="timestamp"> 2010/02/24 18:34:26 </span> <br />
this
</span>
</div>
<div class="clear"></div>
</div>
<div class="padd">
</div>
<ol class="comment">
<li>
<div>Testing </div>
</li>
<li>
<div>Another Test </div>
</li>
</ol>
</li>
</ol>
I m able to hide the nested ols using this code...
$("ol#update li ol").hide();
But still time is being consumed in animating them although they are hidden
I m not able to remove the nested li s using this code
var $li = $("ol#update li").not("ol#update li ol");
$li = $li.not("ol#update li ol");
Take a look at this here
Any help
thanks
Pradyut
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过像这样设置原始列表:
这将仅获取作为
的直接子级的
元素> 列表。
如果您已经设置了不带“>”的
$li
,那么您可以使用“filter”从该列表中删除“嵌套”元素”:
Have you tried setting up your original list like this:
That will get only the
<li>
elements that are direct children of the<ol id="update">
list.If you've already got
$li
set up without the ">", then you can remove the "nested"<li>
elements from that list using "filter":