Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery: don't run script, if it contains .active
    text
    copied!<p>I have a script that animates a menu. I don't want it to if the menu contains an object with an active class (.active). I can't figure it out. I have tried several things, but I guess I'm thinking all wrong. Can you help me?</p> <p>This is the script:</p> <pre><code>$('#navigation .toplevel, #navigation &gt; ul &gt; li').each(function(idx) { $(this).delay( idx * 600 ).fadeIn( 600 ); }); </code></pre> <p>This is the markup:</p> <pre><code>&lt;div id="navigation"&gt; &lt;a href="#" class="toplevel"&gt;Menu&lt;/a&gt; &lt;ul class="undermenu"&gt; &lt;li&gt;&lt;a href="#"&gt;1.0 Menuitem&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#" class="active"&gt;1.1 Menuitem&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;1.2 Menuitem&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;2.0 Menuitem&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;2.1 Menuitem&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;2.2 Menuitem&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>If an UL <strong>does</strong> contain an active-class, I want it to be shown per default and the LI (the parent) to get an .active-class.</p> <p>Does it make any sense? <br><br><br><br></p> <p>*<strong><em>EDIT:</em>*</strong> <br><br></p> <p>The script shall not run if the main UL contains a child (or a childs child) with .active-class. I guess it's a IF/THEN matter? But I don't know how to write it. <br><br>And...<br><br> If "UL LI UL LI <strong>A</strong>" is active the "UL <strong>LI</strong>" (parents, parents, parent :D) should be given .active class. How do I do this? <br><br> Thank you in advance... :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload