Failed to delete nested lists in jQuery variable

I have a nested list that I am animating with 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 nested lists (ol s) or li s in ols

take a look at an example here

Structure of my 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>

I can hide nested ols with this code ...

      $("ol#update li ol").hide();

But still consumed in the animation, although they are hidden

I cannot remove nested faces using this code

var $li = $("ol#update li").not("ol#update li ol");
$li = $li.not("ol#update li ol");

Take a look here

Any help

thanks
Pradyut

0
source share
1 answer

Have you tried customizing the source list as follows:

var $li = $("ol#update > li");

<li>, <ol id="update">.

$li " > ", "" <li> "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)');
+1

Source: https://habr.com/ru/post/1730581/


All Articles