views:

57

answers:

1

Hi
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

+1  A: 

Have 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)');
Pointy
thanks.. it does that...anyway the question was how to remove the nested li's from the variable li ... however still a question....
Pradyut Bhattacharya
OK I'll edit my answer
Pointy
well another question....i can get the 1st element using this...$li = $("ol#update li:eq(0)");how do get the first n elements (only lis) using some code...thanks
Pradyut Bhattacharya
I can get the first n elements using this...$("ol#update li:lt(n)");how do i get the elements between 5 and 10.please reply...
Pradyut Bhattacharya
I m using $li = $li.filter(':lt(5)').filter(':gt(2)');to get lis between 5 and 2;are there other better methods???
Pradyut Bhattacharya
That sounds like a good way to do it! Good luck!
Pointy
I have another question for you...http://stackoverflow.com/questions/2442384/unable-to-apply-jquery-filter
Pradyut Bhattacharya