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
PradyutHave you tried setting up your original list like this:
var $li = $("ol#update > li");
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":
var $li = $('ol#update li'); // gets all <li> elements, even the nested ones
// ...
var $notNested = $li.filter('ol#update > li');
// or, if you prefer,
var $notNested = $li.filter(':not(ol#update li ol li)');
精彩评论